Search code examples
gnuplot

gnuplot named color palette does not work


I want to draw a digital gauge, the range for this gauge will be 0 to 100, with a current temperature of 75.

If I use the classic single palette and color box with a range approach I can get a blue to red gradient (0 to 75) and for the "empty" section of the gauge (75 to 100) I can just display a single color like white of light-dray, there is no problem, it works.

Now, I am trying to use the new named palette feature in version 6.x, as far as I understand it, to have and use multiple palettes on the same plot, but I am not having too much luck.

In the gauge, I want to keep the gradient color from blue to red (0 to 75) and add a gradient color from light-gray to white (75 to 100) but gnuplot is returning an "unexpected or unrecognized token: fullgauge" error...

I have tried using a single named palette, change its name, take out the cbrange command, with no success.

Here is my script:

$DATA<<EOD
270.00,0.50,18.00,0.50,0.00,0.00,1
288.00,0.50,18.00,0.50,0.00,0.00,2
306.00,0.50,18.00,0.50,0.00,0.00,3
324.00,0.50,18.00,0.50,0.00,0.00,4
342.00,0.50,18.00,0.50,0.00,0.00,5
0.00,0.50,18.00,0.50,0.00,0.00,6
18.00,0.50,18.00,0.50,0.00,0.00,7
36.00,0.50,18.00,0.50,0.00,0.00,8
54.00,0.50,18.00,0.50,0.00,0.00,9
72.00,0.50,18.00,0.50,0.00,0.00,10
EOD
set datafile separator comma
set style data points
set polar
set angles degree
set theta top cw
unset rtics; unset raxis
set term windows enhanced
set size square
unset xtics; unset ytics; unset x2tics; unset y2tics
set grid noxtics
set grid noytics
set xrange [-1.5:1.5]
set yrange [-1.5:1.5]
set border 0
set colorsequence classic
set key default
set key off
set palette defined (0 "blue", 1 "red")
set cbrange [1:10]
set colormap new fullgauge
set palette defined (0 "light-gray", 1 "white")
set cbrange [1:10]
set colormap new emptygauge
unset colorbox
set label 1 "CPU" font "Tahoma:Bold,40" at 0,0 center textcolor rgb "black" offset 0,4 front
set label 2 "75.00 C" font "Tahoma:Bold,20" at 0,0 center textcolor rgb "purple" offset 0,1 front
plot $DATA every ::0::7 using 1:2:3:4:5:6:7 with sectors fillstyle solid fc palette fullgauge,\
$DATA every ::8::10 using 1:2:3:4:5:6:7 with sectors fillstyle solid fc palette emptygauge

Thank you for your help

Roberto


Solution

  • I think the only problem with your original code is that you need to set the range of each palette separately and make the range match the actual values you are going to use. Leaving everything the same up to the point of the plot command, I added these commands to get the plot below.

    set style fill solid border lt -1
    set colormap fullgauge range [0:8]
    set colormap emptygauge range [8:10]
    plot $DATA every ::0::7 using 1:2:3:4:5:6:7 with sectors fc palette fullgauge,\
         $DATA every ::8::10 using 1:2:3:4:5:6:7 with sectors fc palette emptygauge
    

    enter image description here