gnuplot:如何在 3D 图形中压制零值

  • 本文关键字:压制 图形 3D gnuplot gnuplot
  • 更新时间 :
  • 英文 :


没有可能,gnuplot 不绘制 z 值为零的区域?

如果我有一个网格,例如:

0  0  24 25
0  23 24 25
23 23 24 0
24 24 0  0

我只想看到"车道",但现在 gnuplot 试图绘制一些(平均值?作为一个文件,我正在获取一些测量值。我的情节配置文件:

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 ):

NaN NaN NaN NaN NaN NaN NaN 100 200
NaN NaN NaN NaN NaN NaN 100 200 100
NaN NaN NaN NaN NaN 100 200 100 NaN
NaN NaN NaN NaN 100 200 100 NaN NaN
NaN NaN NaN 100 200 100 NaN NaN NaN
NaN NaN 100 200 100 NaN NaN NaN NaN
NaN 100 200 100 NaN NaN NaN NaN NaN
100 200 100 NaN NaN NaN NaN NaN NaN
200 100 NaN NaN NaN NaN NaN NaN NaN

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

set datafile missing 'NaN'
set style data lines
splot 'test.dat' matrix  #matrix allows our datafile to look like your first data grid

如果我正确理解您想要什么,如果不将数据放入"网格"格式(使用矩阵或"扫描分隔符"(见下文),您将无法完成它。 dgrid3d在这里不起作用,因为它不知道如何将数据片段指定为缺失。 如果您不想使用matrix格式,可以执行以下操作:

#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.

当然,有了这个分辨率的数据,绘图可能仍然不是你想要的样子,但希望这能证明这一点。

编辑

如果你能把你的数据文件变成你在帖子顶部显示的格式,你有几个(额外的)选项(不要弄乱零):

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

最新更新