我无法通过网络浏览以下简单问题的解决方案:如何使用顶点值绘制3D多边形(例如,填充的矩形或三角形)?我尝试了很多想法,但都失败了,请参阅:from mpl_toolkits.mplot3d import Axes3Dfrom matplotlib.collections import PolyCollectionimport matplotlib.pyplot as pltfig = plt.figure()ax = Axes3D(fig)x = [0,1,1,0]y = [0,0,1,1]z = [0,1,0,1]verts = [zip(x, y,z)]ax.add_collection3d(PolyCollection(verts),zs=z)plt.show()我预先感谢任何想法/意见。根据接受的答案进行更新:import mpl_toolkits.mplot3d as a3import matplotlib.colors as colorsimport pylab as plimport scipy as spax = a3.Axes3D(pl.figure())for i in range(10000): vtx = sp.rand(3,3) tri = a3.art3d.Poly3DCollection([vtx]) tri.set_color(colors.rgb2hex(sp.rand(3))) tri.set_edgecolor('k') ax.add_collection3d(tri)pl.show()结果如下:
添加回答
举报
0/150
提交
取消