我想3D绘制一个数据集,然后将不同的数据集轮廓绘制到单个组合图中。 (对于那些感兴趣的人,轮廓数据集与3Dplot的梯度有关)。改编为from here的代码可以正常工作,除了以下方面:除以下方面:如果我使用set zrange
缩放3D图,轮廓将消失。自动调整后的3Dplot看起来不太好,尽管轮廓看起来还可以,这就是为什么我要应用自定义范围的原因。我怀疑问题也与轮廓线的变化有关,而轮廓线也没有留下轮廓线。但是我对Gnuplot的经验不足,无法确定是否确实如此,或者如何解决问题。
此代码...
reset
set ztics 5
#set zrange [10 : 25] #nowriteback
set view 135,60
set contour base #surface
set cntrlabel font ",7"
set datafile missing "NaN"
set clabel
set cntrparam levels discrete 0.3, 0.4, 0.6, 1.0, 1.5
splot 'out011_Io.txt' nonuniform matrix with lines notitle nocontour, \
'out011_FlxN.txt' nonuniform matrix with lines title "{/Symbol F}_{N}" enhanced nosurface
激活zrange时...
reset
set ztics 5
set zrange [10 : 25] #nowriteback
set view 135,60
set contour base #surface
set cntrlabel font ",7"
set datafile missing "NaN"
set clabel
set cntrparam levels discrete 0.3, 0.4, 0.6, 1.0, 1.5
splot 'out011_Io.txt' nonuniform matrix with lines notitle nocontour, \
'out011_FlxN.txt' nonuniform matrix with lines title "{/Symbol F}_{N}" enhanced nosurface
...创建此图:良好的3D图,没有可见的轮廓。
原始数据可在此处找到:out011_FlxN.txt和out011_Io.txt
对知识渊博的建议表示高度赞赏。
答案 0 :(得分:1)
如果您选中help contour
,则gnuplot提供绘制轮廓的选项
set contour {base | surface | both}
很遗憾,不是您所要求的自定义级别。 因此,我对以下建议的解决方法是:
$Cont
。此数据块将包含数据和轮廓线(在您的情况下为5)以及每个子块,该子块由2条空行分隔。$Cont
,但第一个块除外。您的情况是通过index 1:5
。说明:
for [i=1:LevelCount] $Cont u 1:2:(10):(column(-2)) index i w l lc var ti columnhead(3)
使用以$Cont
为伪列(10)
确定的可变颜色lc var
,以恒定的z级(column(-2))
绘制columnhead(3)
的第1至5个块。显然,在您的情况下,轮廓线只有4条,即0.3
处没有轮廓线。
代码:
### contour plot at custom level
reset session
set contour base
set cntrparam levels discrete 0.3, 0.4, 0.6, 1.0, 1.5
set table $Cont
splot "out011_FlxN2.txt" nonuniform matrix
unset table
unset contour
set key at screen 0.16, screen 1 title "{/Symbol F}_{N}"
set view 135,60
set xyplane relative 0
LevelCount = 5
splot "out011_Io.txt" nonuniform matrix w l notitle, \
for [i=1:LevelCount] $Cont u 1:2:(10):(column(-2)) index i w l lc var ti columnhead(3)
### end of code
结果:
答案 1 :(得分:0)
在没有包含数据文件的最小示例的情况下,很难确定答案,但这可能是因为第二个文件的值超出了您要为第一个文件强加的zrange
。例如,代码:
set cntrparam levels discrete -.5,.5
set contour base
splot 10*(sin(x/3)*sin(y/3)+2), sin(x/3)*sin(y/3) nosurface
会产生轮廓,但是如果您指定不包含zrange
且可能不包含-0.5
的{{1}},也不会显示这些轮廓。由于没有0.5
的{{1}}关键字(与axes
相反),据我所知,您还剩下一些技巧,可以使第二个文件中的数据适合该范围第一的数据。由于第一个的范围是splot
,第二个的范围是plot
,因此添加[10:25]
很好。但是随后您必须“手动”生成关键帧,否则轮廓将被标记为[0.3:1.5]
。这是更正的代码:
10
NB:
10.3, 10.4,...
并计算应向第二个文件中添加什么偏移量,而不是硬设置10。reset
set ztics 5
set zrange [10 : 25] #nowriteback
set view 135,60
set contour base #surface
set cntrlabel font ",7"
set datafile missing "NaN"
set clabel
NSURFACES=1 #change if plotting more surfaces
SHIFT=10
LEVELS="10.3, 10.4, 10.6, 11.0, 11.5"
set cntrparam levels discrete @LEVELS
set style line 100 lc rgb "white"
splot 'out011_Io.txt' nonuniform matrix with lines notitle nocontour, \
'out011_FlxN.txt' nonuniform matrix using 1:2:($3+SHIFT) with lines notitle enhanced nosurface, \
for [i=0:words(LEVELS)] 1/0 w l ls (i==0)?100:i+NSURFACES title (i==0)?"{/Symbol F}_{N}":sprintf(("%.1f"),word(LEVELS,i)-SHIFT)
替换为更干净的stats
关键字。