If I have the following text file:
#text.dat 1 4 #green 2 11 #yellow 3 40 #red
It would be nice to be able to do something like:
set palette defined (0 "green", 10 "yellow", 20 "red") set palette maxcolors 3 plot 'test.dat' using 1:2:2 with boxes palette
At the present (tested on gnuplot4.6.0, OS-X 10.5.8), this doesn't work because gnuplot creates a palette as defined above and then partitions it into 3 separate sections (0-15 is green, 15-30 is yellow, 30-45 is red) which isn't what I asked for in my palette definition. Of course there are numerous workarounds, but they all involve re-mapping the 2nd column using a ternary operator in the using spec (which gets tedious very quickly as the number of colors grows), or adding color information to the datafile and doing some sort of loop:
plot for [color in "green red yellow"] 'test.dat' using 1:(strcol(3) eq color ? $2:NaN):(0.95) with boxes
I'm not saying that palette maxcolors should be overloaded for this purpose -- I just used it as an example as it is the closest thing that I know of that gnuplot currently has to do this task -- but it would be nice if there were some way to set the boundaries for the discrete colors in a palette mapping.
Anyway, thanks for the great work and sorry if this request has been made/turned down before.
This page has an example of the type of plot this would be useful for making:
(the bottom plot turns yellow for KP > 3 and red for KP > 6 -- solar activity is just quiet today). I can imagine it could be useful for all sorts of scripts that have some metric for monitoring something...
See http://i.imgur.com/5zQTSJd.gif for a plot of a day with different colors for the boxes.
The commands you want are
Thanks for the reply. I can see how pinning at either end would make a difference and your solution is already a marked improvement over mine. The thing that would make it better is to somehow relax the "cbrange must match the palette definition range". e.g., something like:
maybe something like
set palette pinned
to pin the pallete to values rather than a portion of the dynamic range...The program does this already. No need for a change.
Closing.