我無法通過網絡瀏覽以下簡單問題的解決方案:如何使用頂點值繪制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
提交
取消