#157 palette maxcolors does not behave as expected when custom palette is defined

open
nobody
None
5
2013-05-07
2013-05-06
No

I'm trying to plot the behaviour of a distributed system as a heat map, using this script:
http://pastebin.com/41WJyHk0
...on this dataset:
http://pastebin.com/tcj1kjyy

This is supposed to show the color-coded state of a number of state machines (y axis) over time (x axis). There are eight states, so I've limited the palette with maxcolors 8. So far so good - as long as I use the built-in palette (comment out line 20):
http://s9.postimg.org/cwgp4xmvz/heatmaps_1.png

If I define my own palette (line 20), things get weird and I get this result:
http://s16.postimg.org/8pt3h9tol/heatmaps_1.png

...which has 13 irregularly-spaced colors on the color bar. To my understanding, the main purpose of the maxcolors option was to adapt to less-capable terminals, so ideally the maxcolors limit should be absolute. Indeed Gnuplot does limit the number of colors, just not to the specified number.

Is this a bug, or did I misunderstand something? I've spent some hours experimenting and googling, but without success.

Discussion

  • Ethan Merritt

    Ethan Merritt - 2013-05-06

    I seem to be incapable of explaining how user-defined palettes work, but please
    see discussion here
    https://sourceforge.net/p/gnuplot/bugs/992/
    https://sourceforge.net/p/gnuplot/bugs/1140/

    It is possible that you will get the results you want if you change the palette definition to:
    set palette defined (
    0 "blue", 1 "blue",
    1 "yellow", 2 "yellow",
    2 "red", 3 "red,
    3 "green", 4 "green",
    4 "brown", 5 "brown",
    5 "black", 6 "black",
    6 "pink", 7 "pink",
    7 "cyan", 8 "cyan" )

    So that each color range has both a start and end point, and in all cases the color is uniform across the specified range.

     
  • Oliver Gehrke

    Oliver Gehrke - 2013-05-07

    That does the trick, thank you very much. Also thank you for linking to the two bug reports which give a bit of background - I hadn't been able to find them in the tracker.

    I don't think you're incapable of explaining how user-defined palettes work - your solution makes immediately and intuitively sense to me. What I think is a bit vague is the description of the effect of the maxcolors option - i.e. I know why your version works, but I still don't have an idea why mine doesn't.

    In one of the bug reports, you say that
    "maxcolors is not important, but it must be at least as large as the number of color ranges."
    This is (somehow) at odds with the description in the manual which says that
    "This option causes N discrete colors to be selected from a continuous palette sampled at equally spaced intervals."
    ...and my own observation that N=8 may give you M=13 colors. IMHO, this is quite confusing.

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks