June 10th, 2012 | 4 Comments
In one off the last entries we defined a color palette similar to the default one in Matlab. Now we will use a color palette with only a few discrete colors, as shown in Fig. 1. This can be useful if we want to see all values from a measurement lying above a given threshold.
Fig. 1 Photoluminescence yield plotted with a palette with discrete colors (code to produce this figure, data)
The trick is to set maxcolors to the number of colors you want in your plot. In addition, the colors to use can be specified by the defined command. Note, that the absolute values you specify in the palette definition were automatically scaled to your min and max values (0 and 18 in this case).
set palette maxcolors 3
set palette defined ( 0 '#000fff',\
1 '#90ff70',\
2 '#ee0000')
How can I plot the colorbox marks labels (2, 4, ….) *inside* the colorbox?
Thanks again for your website!!!
I’ve found it:
set cbtics font “Helvetica,8″ #smaller font
set format cb “%2.0f” #format
set cbtics offset -2 #change location
A much simpler way to do this is to use:
set palette maxcolors N
where N is the number of levels to use.
Thanks, that is a much nicer method.
I have updated the post to include maxcolors.