在splot中断开z轴

时间:2016-03-06 22:31:39

标签: gnuplot

网上有大量资源可以教您如何绘制具有断轴的2d图,例如: http://www.phyast.pitt.edu/~zov1/。基本上使用的策略是使用多时隙模式绘制两个图,并将它们组合在一起。

然而,我希望做的是打破Z轴,考虑这两个表面:

Potential Energy Surface Example

由于两个表面之间的能隙很大,地面能量表面几乎是平坦的。在这个情节中,如果我们单独绘制地面能量表面,我们可以看到它不是平坦的"在所有:

enter image description here

有没有办法打破Z轴使Gnuplot显示更多表面细节? multiplot在这里不起作用,因为它是一个3d图。

1 个答案:

答案 0 :(得分:4)

您可以向上移动上表面并手动重新标记z tics。以这个数字为例:

enter image description here

让我们解决一些gnuplot魔术:

# Make sure that there are no data points exactly at the corners
# of the xy plane (it affects the vertical borders)
set xrange [-1.001:1.001]
set yrange [-1.001:1.001]

zmin = -2
zmax = 5
dz = zmax - zmin
set zrange [zmin:zmax]

# Remove vertical borders
set border 15

# Some functions to plot
f(x,y)=x**2+y**2+10.
g(x,y)=-x**2-y**2

# Draw vertical borders by hand leaving empty space where the
# axis is broken. I have used variables zmin etc. for transparency
set for [i=-1:1:2] for [j=-1:1:2] arrow \
    from i,j,zmin-dz*0.5 to i,j,1 lw 1 nohead
set for [i=-1:1:2] for [j=-1:1:2] arrow \
    from i,j,2 to i,j,zmax lw 1 nohead

# Draw zig-zag line to denote broken axis
set for [i=-1:1:2] for [j=-1:1:2] arrow \
    from i,j,1 to i-0.05,j,1+0.25 lw 1 nohead
set for [i=-1:1:2] for [j=-1:1:2] arrow \
    from i-0.05,j,1+0.25 to i+0.05,j,1+0.75 lw 1 nohead
set for [i=-1:1:2] for [j=-1:1:2] arrow \
    from i+0.05,j,1+0.75 to i,j,2 lw 1 nohead

# Add ztics by hand. Use "for" if you have many tics
set ztics (-2, 0)
# We print the z value - 7, which is the amount we are shifting the
# upper surface
set ztics add ("10" 3, "12" 5)

# Plot shifting the surface
splot f(x,y)-7, g(x,y)

enter image description here

请注意,使用set arrow定义的新边框将绘制在曲面后面。如果您希望特定的一个位于前面,请将其从set for循环中取出并添加front关键字。