Mayavi:曲面图和三维等高线

2024-09-27 04:27:34 发布

您现在位置:Python中文网/ 问答频道 /正文

大家晚上好,我是Matplotlib的长期用户,我最近发现了Mayavi。在

使用Matplotlib,我可以绘制一个三维曲面,其中每个轴的曲面图轮廓都是投影的,我想知道Mayavi是否也可以这样做。在

以下是我迄今为止使用Matplotlib(source)所做的工作的一个例子,但是我在互联网上还没有找到类似的方法用Mayavi绘制等高线:

enter image description here

了解Mayavi的人能否告诉我,我是否可以像Matplotlib一样为每个轴绘制三维轮廓?


Matplotlib代码

from mpl_toolkits.mplot3d import axes3d
import matplotlib.pyplot as plt
from matplotlib import cm

fig = plt.figure()
ax = fig.gca(projection='3d')
X, Y, Z = axes3d.get_test_data(0.05)
ax.plot_surface(X, Y, Z, rstride=8, cstride=8, alpha=0.3)
cset = ax.contour(X, Y, Z, zdir='z', offset=-100, cmap=cm.coolwarm)
cset = ax.contour(X, Y, Z, zdir='x', offset=-40, cmap=cm.coolwarm)
cset = ax.contour(X, Y, Z, zdir='y', offset=40, cmap=cm.coolwarm)

ax.set_xlabel('X')
ax.set_xlim(-40, 40)
ax.set_ylabel('Y')
ax.set_ylim(-40, 40)
ax.set_zlabel('Z')
ax.set_zlim(-100, 100)

plt.show()

马雅维密码

^{pr2}$

Tags: importmatplotlib绘制cmpltaxoffsetcmap

热门问题