简体   繁体   English

在3D轴上绘制2D轮廓集

[英]Plotting a 2D contour set on 3D axes

I am trying to push the limits of the 3D plotting in mpl, I know that they are not a fully featured as they could be and other packages (Mayavi) exist. 我试图在mpl中推动3D绘图的极限,我知道它们并不是功能齐全的,可能存在其他软件包(Mayavi)。 However I would like to do this in mpl if possible. 但是,如果可能,我想在mpl中进行此操作。

I am trying to plot a slice of a 3D array. 我正在尝试绘制3D阵列的一部分。 Ideally I would like to plot an image at the base of my 3D array, however doing it as a filled contour set would be good enough. 理想情况下,我想在3D阵列的底部绘制图像,但是将其作为填充轮廓集就足够了。 At the moment I am doing the following: 目前,我正在执行以下操作:

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
qcset = mpl.contour.QuadContourSet(ax,data[:,:,6],levels=[1])
ax.add_contour_set(qcset)
plt.show()

However this winds me up with blank axes. 但是,这使我陷入空白轴。 I have tried multiple permutations on these few lines but nothing seems to work. 我在这几行上尝试了多种排列,但似乎没有任何效果。

How about using the matplotlib's higher-level contour function: 如何使用matplotlib的高级轮廓函数:

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
cset = ax.contour(data[:,1,1],data[1,:,1],data[1,1,:],zdir='z', offset=-40)
ax.set_zlim(-40, 40)
plt.show()

There are more examples here , specifically this one . 还有更多的例子在这里 ,特别是这一个

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM