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

Skip to content

Commit 80ebe4d

Browse files
authored
Merge pull request #26726 from meeseeksmachine/auto-backport-of-pr-26719-on-v3.8.x
Backport PR #26719 on branch v3.8.x (Fix issue with missing attribute in Path3DCollection)
2 parents b0483da + aa02297 commit 80ebe4d

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

lib/mpl_toolkits/mplot3d/art3d.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -833,6 +833,7 @@ def patch_collection_2d_to_3d(col, zs=0, zdir='z', depthshade=True):
833833
"""
834834
if isinstance(col, PathCollection):
835835
col.__class__ = Path3DCollection
836+
col._offset_zordered = None
836837
elif isinstance(col, PatchCollection):
837838
col.__class__ = Patch3DCollection
838839
col._depthshade = depthshade

lib/mpl_toolkits/mplot3d/tests/test_art3d.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
import numpy as np
2+
13
import matplotlib.pyplot as plt
24

35
from matplotlib.backend_bases import MouseEvent
6+
from mpl_toolkits.mplot3d.art3d import Line3DCollection
47

58

69
def test_scatter_3d_projection_conservation():
@@ -36,3 +39,18 @@ def test_scatter_3d_projection_conservation():
3639
assert contains is True
3740
assert len(ind["ind"]) == 1
3841
assert ind["ind"][0] == i
42+
43+
44+
def test_zordered_error():
45+
# Smoke test for https://github.com/matplotlib/matplotlib/issues/26497
46+
lc = [(np.fromiter([0.0, 0.0, 0.0], dtype="float"),
47+
np.fromiter([1.0, 1.0, 1.0], dtype="float"))]
48+
pc = [np.fromiter([0.0, 0.0], dtype="float"),
49+
np.fromiter([0.0, 1.0], dtype="float"),
50+
np.fromiter([1.0, 1.0], dtype="float")]
51+
52+
fig = plt.figure()
53+
ax = fig.add_subplot(projection="3d")
54+
ax.add_collection(Line3DCollection(lc))
55+
ax.scatter(*pc, visible=False)
56+
plt.draw()

0 commit comments

Comments
 (0)