为了账号安全,请及时绑定邮箱和手机立即绑定

在python-matplotlib中绘制3D多边形

在python-matplotlib中绘制3D多边形

饮歌长啸 2019-11-28 10:01:23
我无法通过网络浏览以下简单问题的解决方案:如何使用顶点值绘制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()结果如下:
查看完整描述

2 回答

  • 2 回答
  • 0 关注
  • 1346 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号