Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbdf5514

Browse files
committed
added test cases for the modification to art3d.py
1 parent5a51e6a commitbdf5514

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

‎lib/mpl_toolkits/mplot3d/tests/test_art3d.py

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
importmatplotlib.pyplotasplt
44

55
frommatplotlib.backend_basesimportMouseEvent
6-
frommpl_toolkits.mplot3d.art3dimportLine3DCollection
6+
frommpl_toolkits.mplot3d.art3dimportLine3DCollection,Poly3DCollection
77

88

99
deftest_scatter_3d_projection_conservation():
@@ -54,3 +54,32 @@ def test_zordered_error():
5454
ax.add_collection(Line3DCollection(lc))
5555
ax.scatter(*pc,visible=False)
5656
plt.draw()
57+
58+
59+
deftest_generate_normals():
60+
61+
# Following code is an example taken from
62+
# https://stackoverflow.com/questions/18897786/transparency-for-poly3dcollection-plot-in-matplotlib
63+
# and modified to test _generate_normals function
64+
65+
fig=plt.figure()
66+
ax=fig.add_subplot(111,projection='3d')
67+
68+
x= [0,2,1,1]
69+
y= [0,0,1,0]
70+
z= [0,0,0,1]
71+
72+
# deliberately use nested tuple
73+
vertices= ((0,1,2), (0,1,3), (0,2,3), (1,2,3))
74+
75+
tupleList=list(zip(x,y,z))
76+
77+
poly3d= [[tupleList[vertices[ix][iy]]foriyinrange(len(vertices[0]))]
78+
forixinrange(len(vertices))]
79+
ax.scatter(x,y,z)
80+
collection=Poly3DCollection(poly3d,alpha=0.2,edgecolors='r',shade=True)
81+
face_color= [0.5,0.5,1]# alternative: matplotlib.colors.rgb2hex([0.5, 0.5, 1])
82+
collection.set_facecolor(face_color)
83+
ax.add_collection3d(collection)
84+
85+
plt.draw()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp