Gnuplot pm3d:'NaN value' 删除所有周围的矩形

Gnuplot pm3d: 'NaN value' removes all surrounding rectangles

我想绘制一个 pm3d 地图,其中数据点在轴上的距离不等。 由于 x 轴和 y 轴的间距相同,所以它是对称的。

问题是每当值为 "NaN" 时,周围的所有四个矩形 没有绘制。例如,在下面的数据文件中,这种情况发生在 (x,y)=(0.14,0.33) .

如果值不是'NaN',则四个矩形重新出现。 我发现了这个问题,当我试图只绘制值 >0 或 <0 时,同样的情况发生了。

我试图搜索文档和互联网,但找不到任何相关内容。 有解决办法吗?

剧情:

set view map
set pm3d at b
set style data pm3d
set pm3d corners2color c1
set size ratio 1
set autoscale fix
set cbrange [-25:25]
set palette defined (-25 "blue", 0 "white", 25 "red")
set term png
set output "test.png"
splot "data.txt" u 1:2:3 notitle
set output

数据文件:

0.0 0.0 1
0.0 0.08 -2
0.0 0.14 3
0.0 0.33 -4
0.0 0.46 5
0.0 0.55 5

0.08 0.0 -6
0.08 0.08 7
0.08 0.14 -8
0.08 0.33 9
0.08 0.46 -10
0.08 0.55 -10

0.14 0.0 11
0.14 0.08 -12
0.14 0.14 13
0.14 0.33 NaN
0.14 0.46 15
0.14 0.55 15

0.33 0.0 -16
0.33 0.08 17
0.33 0.14 -18
0.33 0.33 19
0.33 0.46 -20
0.33 0.55 -20

0.46 0.0 21
0.46 0.08 -22
0.46 0.14 23
0.46 0.33 -24
0.46 0.46 25
0.46 0.55 25

0.55 0.0 21
0.55 0.08 -22
0.55 0.14 23
0.55 0.33 -24
0.55 0.46 25
0.55 0.55 25

感谢@theozh 的评论,我找到了解决这个问题的方法。 我采用了@theozh 在 下的脚本到下面的表格。这会产生文件

1 -6 11 -16 21
-2 7 -12 17 -22
3 -8 13 -18 23
-4 9 NaN 19 -24
5 -10 15 -20 25

这个plot. 这是最好的解决方案,因为无论如何数据都是这种格式,而且坐标是我读入的不同文件。 剧情:

CoordsX = "0.04 0.11 0.24 0.40 0.51"
CoordsY = "0.04 0.11 0.24 0.40 0.51"
dimX = words(CoordsX)
dimY = words(CoordsY)
dx(i) = (word(CoordsX,i)-word(CoordsX,i-1))*0.5
dy(i) = (word(CoordsY,i)-word(CoordsY,i-1))*0.5
ndx(i,j) = word(CoordsX,i) - (i-1<1        ? dx(i+1) : dx(i))
pdx(i,j) = word(CoordsX,i) + (i+1>ColCount ? dx(i)   : dx(i+1))
ndy(i,j) = word(CoordsY,j) - (j-1<1        ? dy(j+1) : dy(j))
pdy(i,j) = word(CoordsY,j) + (j+1>RowCount ? dy(j)   : dy(j+1))

set xrange[ndx(1,1):pdx(ColCount,1)]
set yrange[ndy(1,1):pdy(1,RowCount)]
set tic out
max = 25
set cbrange [-max:max]
set palette defined (-max "blue", 0 "white", max "red")

set term png
set output "test.png"
plot for [i=1:dim_x] file u (real(word(CoordsX,i))):1:(ndx(i,int([=11=]))):(pdx(i,int([=11=]))):(ndy(i,int([=11=]+1))):(pdy(i,int([=11=]+1))):i with boxxyerror fs solid 1.0 palette notitle
set output
### end of code