Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4eeba2a

Browse files
Merge pull request #29285 from scottshambaugh/gh_29156
2 parents 8d8751d + e5f5765 commit 4eeba2a

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

lib/mpl_toolkits/mplot3d/art3d.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1382,6 +1382,7 @@ def _generate_normals(polygons):
13821382
v2 = np.empty((len(polygons), 3))
13831383
for poly_i, ps in enumerate(polygons):
13841384
n = len(ps)
1385+
ps = np.asarray(ps)
13851386
i1, i2, i3 = 0, n//3, 2*n//3
13861387
v1[poly_i, :] = ps[i1, :] - ps[i2, :]
13871388
v2[poly_i, :] = ps[i2, :] - ps[i3, :]

lib/mpl_toolkits/mplot3d/tests/test_art3d.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33
import matplotlib.pyplot as plt
44

55
from matplotlib.backend_bases import MouseEvent
6-
from mpl_toolkits.mplot3d.art3d import Line3DCollection, _all_points_on_plane
6+
from mpl_toolkits.mplot3d.art3d import (
7+
Line3DCollection,
8+
Poly3DCollection,
9+
_all_points_on_plane,
10+
)
711

812

913
def test_scatter_3d_projection_conservation():
@@ -85,3 +89,14 @@ def test_all_points_on_plane():
8589
# All points lie on a plane
8690
points = np.array([[0, 0, 0], [0, 1, 0], [1, 0, 0], [1, 1, 0], [1, 2, 0]])
8791
assert _all_points_on_plane(*points.T)
92+
93+
94+
def test_generate_normals():
95+
# Smoke test for https://github.com/matplotlib/matplotlib/issues/29156
96+
vertices = ((0, 0, 0), (0, 5, 0), (5, 5, 0), (5, 0, 0))
97+
shape = Poly3DCollection([vertices], edgecolors='r', shade=True)
98+
99+
fig = plt.figure()
100+
ax = fig.add_subplot(projection='3d')
101+
ax.add_collection3d(shape)
102+
plt.draw()

0 commit comments

Comments
 (0)