Skip to content

Commit 595f639

Browse files
Remove depthshade getters
getter make depthshade_minalpha kwarg only kwarg order getter Update image test failures Linting fix masked scatter depth shading removed depthshade check fix tests
1 parent 0a41236 commit 595f639

File tree

9 files changed

+9
-20
lines changed

9 files changed

+9
-20
lines changed

lib/mpl_toolkits/mplot3d/art3d.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
path as mpath)
1919
from matplotlib.collections import (
2020
Collection, LineCollection, PolyCollection, PatchCollection, PathCollection)
21-
from matplotlib.colors import Normalize
2221
from matplotlib.patches import Patch
2322
from . import proj3d
2423

@@ -663,9 +662,6 @@ def __init__(
663662
def get_depthshade(self):
664663
return self._depthshade
665664

666-
def get_depthshade_minalpha(self):
667-
return self._depthshade_minalpha
668-
669665
def set_depthshade(
670666
self,
671667
depthshade,
@@ -773,7 +769,7 @@ def _get_data_scale(X, Y, Z):
773769
return 0
774770

775771
# Estimate the scale using the RSS of the ranges of the dimensions
776-
return np.sqrt(np.ptp(X) ** 2 + np.ptp(Y) ** 2 + np.ptp(Z) ** 2)
772+
return np.sqrt(np.ma.ptp(X) ** 2 + np.ma.ptp(Y) ** 2 + np.ma.ptp(Z) ** 2)
777773

778774

779775
class Path3DCollection(PathCollection):
@@ -889,9 +885,6 @@ def set_linewidth(self, lw):
889885
def get_depthshade(self):
890886
return self._depthshade
891887

892-
def get_depthshade_minalpha(self):
893-
return self._depthshade_minalpha
894-
895888
def set_depthshade(
896889
self,
897890
depthshade,
@@ -999,8 +992,9 @@ def patch_collection_2d_to_3d(
999992
zs=0,
1000993
zdir="z",
1001994
depthshade=True,
1002-
depthshade_minalpha=0.3,
1003995
axlim_clip=False,
996+
*args,
997+
depthshade_minalpha=0.3
1004998
):
1005999
"""
10061000
Convert a `.PatchCollection` into a `.Patch3DCollection` object
@@ -1023,7 +1017,6 @@ def patch_collection_2d_to_3d(
10231017
Sets the minimum alpha value used by depth-shading. Default: 0.3.
10241018
axlim_clip : bool, default: False
10251019
Whether to hide patches with a vertex outside the axes view limits.
1026-
10271020
"""
10281021
if isinstance(col, PathCollection):
10291022
col.__class__ = Path3DCollection

lib/mpl_toolkits/mplot3d/axes3d.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2904,8 +2904,8 @@ def add_collection3d(self, col, zs=0, zdir='z', autolim=True, *,
29042904
"edgecolors", "c", "facecolor",
29052905
"facecolors", "color"])
29062906
def scatter(self, xs, ys, zs=0, zdir='z', s=20, c=None, depthshade=True,
2907+
*args,
29072908
depthshade_minalpha=0.3,
2908-
*args,
29092909
axlim_clip=False,
29102910
**kwargs):
29112911
"""
@@ -2987,8 +2987,7 @@ def scatter(self, xs, ys, zs=0, zdir='z', s=20, c=None, depthshade=True,
29872987
depthshade=depthshade,
29882988
depthshade_minalpha=depthshade_minalpha,
29892989
axlim_clip=axlim_clip,
2990-
)
2991-
2990+
)
29922991
if self._zmargin < 0.05 and xs.size > 0:
29932992
self.set_zmargin(0.05)
29942993

-4.4 KB
Loading
5.03 KB
Loading
4.86 KB
Loading
-267 Bytes
Loading
-349 Bytes
Loading
2 Bytes
Loading

lib/mpl_toolkits/mplot3d/tests/test_axes3d.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,6 @@ def test_tight_layout_text(fig_test, fig_ref):
409409

410410
@mpl3d_image_comparison(['scatter3d.png'], style='mpl20')
411411
def test_scatter3d():
412-
plt.rcParams['axes3d.automargin'] = True # Remove when image is regenerated
413412
fig = plt.figure()
414413
ax = fig.add_subplot(projection='3d')
415414
ax.scatter(np.arange(10), np.arange(10), np.arange(10),
@@ -423,7 +422,6 @@ def test_scatter3d():
423422

424423
@mpl3d_image_comparison(['scatter3d_color.png'], style='mpl20')
425424
def test_scatter3d_color():
426-
plt.rcParams['axes3d.automargin'] = True # Remove when image is regenerated
427425
fig = plt.figure()
428426
ax = fig.add_subplot(projection='3d')
429427

@@ -467,7 +465,7 @@ def test_scatter3d_modification(fig_ref, fig_test):
467465
# Changing Path3DCollection properties post-creation should work correctly.
468466
ax_test = fig_test.add_subplot(projection='3d')
469467
c = ax_test.scatter(np.arange(10), np.arange(10), np.arange(10),
470-
marker='o')
468+
marker='o', depthshade=True)
471469
c.set_facecolor('C1')
472470
c.set_edgecolor('C2')
473471
c.set_alpha([0.3, 0.7] * 5)
@@ -483,13 +481,13 @@ def test_scatter3d_modification(fig_ref, fig_test):
483481
depthshade=False, s=75, linewidths=3)
484482

485483

486-
@pytest.mark.parametrize('depthshade', [True, False])
487484
@check_figures_equal(extensions=['png'])
488-
def test_scatter3d_sorting(fig_ref, fig_test, depthshade):
485+
def test_scatter3d_sorting(fig_ref, fig_test):
489486
"""Test that marker properties are correctly sorted."""
490487

491488
y, x = np.mgrid[:10, :10]
492489
z = np.arange(x.size).reshape(x.shape)
490+
depthshade = False
493491

494492
sizes = np.full(z.shape, 25)
495493
sizes[0::2, 0::2] = 100
@@ -882,7 +880,6 @@ def test_mixedsamplesraises():
882880
# remove tolerance when regenerating the test image
883881
@mpl3d_image_comparison(['quiver3d.png'], style='mpl20', tol=0.003)
884882
def test_quiver3d():
885-
plt.rcParams['axes3d.automargin'] = True # Remove when image is regenerated
886883
fig = plt.figure()
887884
ax = fig.add_subplot(projection='3d')
888885
pivots = ['tip', 'middle', 'tail']
@@ -960,7 +957,7 @@ def test_patch_collection_modification(fig_test, fig_ref):
960957
patch1 = Circle((0, 0), 0.05)
961958
patch2 = Circle((0.1, 0.1), 0.03)
962959
facecolors = np.array([[0., 0.5, 0., 1.], [0.5, 0., 0., 0.5]])
963-
c = art3d.Patch3DCollection([patch1, patch2], linewidths=3)
960+
c = art3d.Patch3DCollection([patch1, patch2], linewidths=3, depthshade=True)
964961

965962
ax_test = fig_test.add_subplot(projection='3d')
966963
ax_test.add_collection3d(c)

0 commit comments

Comments
 (0)