Skip to content

Commit

Permalink
Merge pull request #26726 from meeseeksmachine/auto-backport-of-pr-26…
Browse files Browse the repository at this point in the history
…719-on-v3.8.x

Backport PR #26719 on branch v3.8.x (Fix issue with missing attribute in Path3DCollection)
  • Loading branch information
QuLogic committed Sep 8, 2023
2 parents b0483da + aa02297 commit 80ebe4d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/mpl_toolkits/mplot3d/art3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -833,6 +833,7 @@ def patch_collection_2d_to_3d(col, zs=0, zdir='z', depthshade=True):
"""
if isinstance(col, PathCollection):
col.__class__ = Path3DCollection
col._offset_zordered = None
elif isinstance(col, PatchCollection):
col.__class__ = Patch3DCollection
col._depthshade = depthshade
Expand Down
18 changes: 18 additions & 0 deletions lib/mpl_toolkits/mplot3d/tests/test_art3d.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import numpy as np

import matplotlib.pyplot as plt

from matplotlib.backend_bases import MouseEvent
from mpl_toolkits.mplot3d.art3d import Line3DCollection


def test_scatter_3d_projection_conservation():
Expand Down Expand Up @@ -36,3 +39,18 @@ def test_scatter_3d_projection_conservation():
assert contains is True
assert len(ind["ind"]) == 1
assert ind["ind"][0] == i


def test_zordered_error():
# Smoke test for https://github.com/matplotlib/matplotlib/issues/26497
lc = [(np.fromiter([0.0, 0.0, 0.0], dtype="float"),
np.fromiter([1.0, 1.0, 1.0], dtype="float"))]
pc = [np.fromiter([0.0, 0.0], dtype="float"),
np.fromiter([0.0, 1.0], dtype="float"),
np.fromiter([1.0, 1.0], dtype="float")]

fig = plt.figure()
ax = fig.add_subplot(projection="3d")
ax.add_collection(Line3DCollection(lc))
ax.scatter(*pc, visible=False)
plt.draw()

0 comments on commit 80ebe4d

Please sign in to comment.