matplotlib三维表面图没有显示 [英] matplotlib 3d surface plots not showing
本文介绍了matplotlib三维表面图没有显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想作一个简单的三维表面的情节与matplotlib但情节并不在年底显现。我只能得到一个空的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 an empty 3D axes. Here is what I did
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()
所以,我得到这个
So I get this
有什么建议?
推荐答案
您没有绘制表面: X
,是
和以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三维表面图没有显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文