首页 > 解决方案 > Gnuplot pm3d 绘制“inf”值白色

问题描述

我正在使用这些选项来绘制能量表面的 3D 地图。

set cbrange [-60:60]
 
set palette maxcolors 13 model RGB defined (0 "#0ab3f7",1 "#4dabec",2 "#6da2df", 3 "#8599d3", 4 "#9a8fc5",5 "#ac84b6", 6 "#bc79a7", 7 "#cc6c95", 8 "#da5d81",9 "#e74c69", 10 "#f3364a", 11 "#f4344
7", 12 "#ff0000") 

set cbtics ("-50" -50, "-40" -40, "-30" -30 , "-20" -20, "-10" -10, "0" 0, "10" 10, "20" 20, "30" 30, "40" 40, "50" 50, "inf" 60)

但不能给 inf 值任何颜色。我怎样才能做到这一点 ?

在此处输入图像描述

标签: gnuplot

解决方案


如果您的数据实际上包含 Inf 或 -Inf,这应该会自动发生。这是在线演示集合imageNaN.dem中的第一个图。

# This is the first plot from "imageNaN.dem" in the gnuplot demo set
#
set title "Treatment of missing/undefined/NaN/Inf data"
unset key
set tic scale 0
set border 3 front

set cbrange [-2:7]
set cblabel "Score"
set cbtics 0,1,5

set xrange [-0.5:4.5]
set yrange [-0.5:5.5]

set datafile missing "?"
set ytics ("-Inf" 5, "Inf" 4, "NaN" 3, "Junk" 2, "?" 1, "0" 0)
unset xtics

# Define the test data as a named data block
$matrixdata << EOD
0    5 4 3  0
?    2 2 0  1
Junk 1 2 3  5
NaN  0 0 3  0
Inf  3 2 0  3
-Inf 0 1 2  3
EOD

set view map
plot $matrixdata matrix with image 

在此处输入图像描述


推荐阅读