Search code examples
gnuplotbackground-color

How can I set the background gradually based on data


I try to paint the background more "red" the higher the number in colon 2 is. But I have no luck getting this done.

set terminal wx size 700,300
set palette defined (0 "white", 1 "red")
set autoscale cbfix
set autoscale xfix
set autoscale yfix
set y2range [0:1]
set y2tics

$data << EOD
1501293600  0   2348.81
1501297200  8   2338.23
1501300800  7   2325.25
1501304400  16  2349.49
1501308000  13  2354.78
1501311600  18  2349.97
1501315200  14  2361.19
1501318800  16  2350.1
1501322400  8   2325.57
1501326000  12  2296.07
1501329600  24  2309.74
1501333200  30  2301.21
1501336800  30  2308.85
1501340400  19  2321.49
1501344000  24  2315.54
1501347600  17  2331.58
1501351200  17  2350.56
1501354800  20  2344.22
1501358400  15  2339.81
1501362000  19  2326.6
1501365600  8   2313.58
1501369200  13  2318.37
EOD

plot '$data' using 1:(1):2 with image axes x1y2, \  # just use 1 (the max y2 value) as y value
     '$data' using 1:3 with lines axes x1y1

Solution

  • You can try to use a colored box style instead of image style:

    set style fill solid
    plot '$data' using 1:(1):2 with boxes linecolor palette axes x1y2, \
         '$data' using 1:3 with lines axes x1y1
    

    The result:

    background colored by column