gnuplot热图的颜色范围 [英] gnuplot heat map color range
问题描述
我有一些X Y Z数据在一个文件,我正在使用gnuplot来显示它。
我正在创建一个热图,即。使用颜色呈现Z值的2D图。
现在我使用以下脚本:
设置调色板定义(0蓝色,1红色)
plotxyz.datu $ 1:$ 2:$ 3 w image
我的问题是,gnuplot忽略调色板定义中的0和1。它使用指定的颜色,但根据文件中的最小和最大Z值重新调整。
这使得很难在视觉上比较z范围不同的不同图。
如何告诉gnuplot停止重新缩放z颜色范围?
调色板定义命令映射灰色值,如果您使用灰度绘制到调色板上,缩放到min - > 0和max - > 1是如何工作的。如果要使一组绘图全部使用相同的数据缩放,则要使用set cbrange命令。例如,
set cbrange [0:0.5]
设置调色板定义(0蓝色,1红色)
splot'++'使用1:2:(sin($ 1)* cos($ 2))w image
给你一个图像绘图,最大数据值为0.5,映射到红色,0映射到蓝色。
随后的图,如
splot'++'使用1:2:(0.5 * sin($ 1)* cos($ 2))w image
将使用相同的缩放比例,因此可以进行比较。 p>
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.
这篇关于gnuplot热图的颜色范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!