Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gnuplot heat map color range

Tags:

map

gnuplot

heat

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?

like image 585
Marton Trencseni Avatar asked Aug 03 '12 06:08

Marton Trencseni


1 Answers

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.

like image 164
Lee Phillips Avatar answered Sep 21 '22 12:09

Lee Phillips