matplotlib 3d 曲面图未显示 [英] matplotlib 3d surface plots not showing
本文介绍了matplotlib 3d 曲面图未显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用 matplotlib 制作一个简单的 3D 曲面图,但该图最后没有显示;我只得到空的 3D 轴.
I am trying to make a simple 3D surface plot with matplotlib but the plot does not show at the end; I only get empty 3D axes.
这是我所做的:
from mpl_toolkits.mplot3d import Axes3D
x = np.arange(1, 100, 1)
y = np.arange(1, 100, 1)
z = np.arange(1, 100, 1)
fig = figure()
ax = fig.add_subplot(111, projection='3d')
ax.plot_surface(x, y, z, rstride=5, cstride=5)
show()
...我明白了:
有什么建议吗?
推荐答案
您不是在绘制曲面:x
、y
和 z
需要是二维数组.看这个例子:http://matplotlib.org/examples/mplot3d/surface3d_demo.html.
You are not plotting a surface: x
, y
and z
needs to be 2D arrays. Look at this example: http://matplotlib.org/examples/mplot3d/surface3d_demo.html.
这篇关于matplotlib 3d 曲面图未显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文