Search code examples
gnuplotpointvarpalette

How to use "var" and "palette" together in gnuplot?


gnuplot script:

set xrange [25:60]
set yrange [45:80]
set palette defined(1 "red", 2 "green", 3 "blue")
unset key
unset colorbox
plot 'test.data' using 1:2:3:4 with points pt 7 ps var lt palette

test.data

x       y       count   color
30      50      4       1
35      55      3       1
40      60      2       2
45      65      5       2
50      70      4       3
55      75      2       3

output: enter image description here

I need so: enter image description here

How to use "var" and "palette" together in gnuplot?

gnuplot Version 4.4 patchlevel 3


Solution

  • Seems like the autoscaling of the color range doesn't work properly in this case with version 4.4.3 (with 4.6.5 your script works out of the box). Also using set autoscale cbfix doesn't works as it seems to use the values of the third column for the scaling. (comment out unset colorbox to see this).

    If you explicitely set a color range, it works fine also with 4.4.3:

    set xrange [25:60]
    set yrange [45:80]
    
    set cbrange [1:3]    
    
    set palette defined(1 "red", 2 "green", 3 "blue")
    unset key
    unset colorbox
    plot 'test.data' using 1:2:3:4 with points pt 7 ps var lt palette