gnuplot:如何在三维图形中抑制零值?

gnuplot:如何在三维图形中抑制零值?,gnuplot,Gnuplot,gnuplot是否可能不绘制z值为零的区域 如果我有一个网格,如: 0 0 24 25 0 23 24 25 23 23 24 0 24 24 0 0 我只想看到“lane”,但现在gnuplot尝试绘制一些(mean?)值,其中的零是。 作为一个文件,我取了一些测量值。 绘图的我的配置文件: set grid lt 2 lw 1 set surface set parametric set xtics set ytics set style data lines set dgrid3

gnuplot是否可能不绘制z值为零的区域

如果我有一个网格,如:

0  0  24 25
0  23 24 25
23 23 24 0
24 24 0  0
我只想看到“lane”,但现在gnuplot尝试绘制一些(mean?)值,其中的零是。 作为一个文件,我取了一些测量值。 绘图的我的配置文件:

set grid lt 2 lw 1
set surface
set parametric
set xtics
set ytics
set style data lines
set dgrid3d 80,80,3
splot file
此网格的数据文件为:

1 3 24
1 4 25
2 2 23 
2 3 24
2 4 25
3 1 23
3 2 23
3 3 24
4 1 24
4 2 24 

因此,数据文件中没有零。

我很难准确理解您想要做什么,但希望下面的内容会有所帮助

假设我们有一个数据文件(
test.dat
):

我们可以使用以下方法绘制此数据文件:

set datafile missing 'NaN'
set style data lines
splot 'test.dat' matrix  #matrix allows our datafile to look like your first data grid
如果我正确理解了您的需求,那么如果不将数据转换为“网格”格式(使用矩阵或“扫描分隔符”(见下文),您将无法完成此任务.
dgrid3d
在这里不起作用,因为它不知道如何将数据段指定为缺失。如果不想使用
矩阵
格式,可以执行以下操作:

#Note the blank spaces!
#Each block doesn't have to have the same number of lines
#but the resulting plot looks nicest if it does.
#for lines that you want to make blank, use some character to
#mark that data as missing.  (I used 'NaN' above, but you can
#use anything you want.  sometimes I use '?' too).
x1 y1 num
x1 y2 num
x1 y3 num
...

x2 y1 num
x2 y2 num
x2 y3 num
...               

...

xN y1 num
xN y2 num
xN y3 num
...
具体示例:对于网格:

1 1 ?
1 2 ?
1 3 24
1 4 25

2 1 ?
2 2 23 
2 3 24
2 4 25

3 1 23
3 2 23
3 3 24
3 4 ?

4 1 24
4 2 24 
4 3 ?
4 4 ?
然后:

set datafile missing '?'
set style data lines
splot 'my_data.txt'  #Not matrix this time.
当然,对于这个分辨率的数据,绘图仍然可能看起来不是您想要的样子,但希望这能证明这一点

编辑

如果您可以将数据文件转换为文章顶部显示的格式,那么您有几个(附加)选项(不必弄乱零):

或:


我的测量文件有数百个测量值。我试图在一本手册上添加NaN值,但绘图是相同的。对于NaN值,绘图只是获取一些——在我的情况下是不合理的——值。我真的不打算为了得到一个好看的图而伪造数据。我不知道“伪造数据”是什么意思--您发布的数据文件中缺少数据值。我只是明确地告诉gnuplot这一事实。在任何情况下,如果您希望数据文件中有零,您可以这样做
设置数据文件缺少“0”
。或者,您可以将它们放在那里并设置z范围。至于NaN值不起作用,您是否仍在使用
dgrid3d?正如我所说,
dgrid3d
在这里不起作用。您是否也将数据文件转换为griddata格式,还是将其保留为单个点列表?
set datafile missing '?'
set style data lines
splot 'my_data.txt'  #Not matrix this time.
set datafile missing '0'  #This just has the effect of removing the 0 values from the plot
splot 'myfile.txt' matrix
set zrange [0.5:]   #This also removes the 0 values, but alters the z-range.
splot 'myfile.txt' matrix