gnuplot heat map color range

て烟熏妆下的殇ゞ 提交于 2019-12-07 00:33:42

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/11790804/gnuplot-heat-map-color-range

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!