z轴中的坐标轴损坏 [英] Broken z-axis in splot

查看:99
本文介绍了z轴中的坐标轴损坏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在线上有很多资源可以教您如何绘制断轴的二维图,例如 http://www.phyast.pitt.edu/~zov1/.基本上,使用的策略是使用多图模式绘制两个图,并将它们组合在一起.

但是,我希望做的是折断Z轴,请考虑以下两个表面:

由于两个表面之间的巨大能隙,因此在此图中,地面能量表面几乎是平坦的",但是,如果仅绘制地面能量表面,则可以看到它根本不是平坦的":

是否可以折断Z轴以使Gnuplot显示更多表面细节? multiplot在这里不起作用,因为它是3d图.

解决方案

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

让我们研究一些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)

请注意,用set arrow定义的新边框将在表面后面绘制.如果您希望某个特定对象位于最前面,则将其从set for循环中删除,并在其中添加front关键字.

There are plenty of resources online to teach you how to draw 2d plots with broken axis, e.g. http://www.phyast.pitt.edu/~zov1/. Basically what strategy used was to draw two plots using multiplot mode, and combine them together.

However, what I wished to do is to break the Z axis, consider these two surfaces:

Because of the large energy gap between two surfaces, the ground energy surface is almost "flat" in this plot, yet if we plot the ground energy surface alone, we can see it is not "flat" at all:

Is there a way of breaking the Z axis to make Gnuplot display more details of the surface? multiplot does not work here because it is a 3d plot.

解决方案

You can shift the upper surface downwards and relabel the z tics manually. Take this figure as an example:

Let's work out some gnuplot magic:

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

Note that the new borders defined with set arrow will be drawn behind the surface. If you want a particular one to be in the front, then take it out of the set for loop and add the front keyword to it.

这篇关于z轴中的坐标轴损坏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆