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

Appearance settings

Commit 5a6411d

Browse filesBrowse files
committed
MNT: slightly re-organize code and clarify docstrings
1 parent 8c62c10 commit 5a6411d
Copy full SHA for 5a6411d

File tree

Expand file treeCollapse file tree

1 file changed

+23
-20
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+23
-20
lines changed

‎lib/mpl_toolkits/mplot3d/art3d.py

Copy file name to clipboardExpand all lines: lib/mpl_toolkits/mplot3d/art3d.py
+23-20Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -546,9 +546,16 @@ def set_3d_properties(self, zs, zdir):
546546
xs = []
547547
ys = []
548548
self._offsets3d = juggle_axes(xs, ys, np.atleast_1d(zs), zdir)
549-
# grab the current sizes as-is
550549
# In the base draw methods we access the attributes directly which
551-
# means we can not buffer the shuffling on the way out.
550+
# means we can not resolve the shuffling in the getter methods like
551+
# we do for the edge and face colors.
552+
#
553+
# This means we need to carry around a cache of the unsorted sizes and
554+
# widths (postfixed with 3d) and in `do_3d_projection` set the
555+
# depth-sorted version of that data into the private state used by the
556+
# base collection class in its draw method.
557+
#
558+
# grab the current sizes and linewidths to preserve them
552559
self._sizes3d = self._sizes
553560
self._linewidths3d = self._linewidths
554561
xs, ys, zs = self._offsets3d
@@ -617,30 +624,26 @@ def do_3d_projection(self, renderer=None):
617624

618625
return np.min(vzs) if vzs.size else np.nan
619626

620-
def get_facecolor(self):
621-
bc = super().get_facecolor()
622-
fcs = (
623-
_zalpha(bc, self._vzs)
627+
def _maybe_depth_shade_and_sort_colors(self, color_array):
628+
color_array = (
629+
_zalpha(color_array, self._vzs)
624630
if self._vzs is not None and self._depthshade
625-
else bc
631+
else color_array
626632
)
627-
if len(fcs) > 1:
628-
fcs = fcs[self._z_markers_idx]
629-
return mcolors.to_rgba_array(fcs, self._alpha)
633+
if len(color_array) > 1:
634+
color_array = color_array[self._z_markers_idx]
635+
return mcolors.to_rgba_array(color_array, self._alpha)
636+
637+
def get_facecolor(self):
638+
return self._maybe_depth_shade_and_sort_colors(super().get_facecolor())
630639

631640
def get_edgecolor(self):
641+
# We need this check here to make sure we do not double-apply the based
642+
# depth alpha shading when the edge color is "face" which means the
643+
# edge colour should be identical to the face colour.
632644
if cbook._str_equal(self._edgecolors, 'face'):
633645
return self.get_facecolor()
634-
635-
bc = super().get_edgecolor()
636-
ecs = (
637-
_zalpha(bc, self._vzs)
638-
if self._vzs is not None and self._depthshade
639-
else bc
640-
)
641-
if len(ecs) > 1:
642-
ecs = ecs[self._z_markers_idx]
643-
return mcolors.to_rgba_array(ecs, self._alpha)
646+
return self._maybe_depth_shade_and_sort_colors(super().get_edgecolor())
644647

645648

646649
def patch_collection_2d_to_3d(col, zs=0, zdir='z', depthshade=True):

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.