I have some X Y Z data in a file and I'm using gnuplot to display it. I am creating a heat map, ie. a 2D plot where the Z value is presented using color. Right now I'm using the following script:
set palette defined (0 "blue", 1 "red")
plot "xyz.dat" u $1:$2:$3 w image
My problem is, gnuplot ignores the 0 and 1 in the palette definition. It uses the colors specified, but rescales according to the minimal and maximal Z value in the file. This makes it hard to visually compare different plots whose z range is different.
How do I tell gnuplot to stop rescaling the z color range?
The "set palette defined" command maps the grey values that you would get if you were plotting using greyscale onto a color palette; the scaling to min -> 0 and max -> 1 is how it's supposed to work. If you want to make a set of plots all with the same scaling of the data, you want to use the "set cbrange" command. For example,
set cbrange [0:0.5]
set palette defined (0 "blue", 1 "red")
splot '++' using 1:2:(sin($1)*cos($2)) w image
gives you an image plot with the maximum data value of 0.5 mapped to red and 0 mapped to blue. Subsequent plots, like
splot '++' using 1:2:(0.5*sin($1)*cos($2)) w image
will use the same scaling, so they can be compared.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With