@@ -546,9 +546,16 @@ def set_3d_properties(self, zs, zdir):
546
546
xs = []
547
547
ys = []
548
548
self ._offsets3d = juggle_axes (xs , ys , np .atleast_1d (zs ), zdir )
549
- # grab the current sizes as-is
550
549
# 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
552
559
self ._sizes3d = self ._sizes
553
560
self ._linewidths3d = self ._linewidths
554
561
xs , ys , zs = self ._offsets3d
@@ -617,30 +624,26 @@ def do_3d_projection(self, renderer=None):
617
624
618
625
return np .min (vzs ) if vzs .size else np .nan
619
626
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 )
624
630
if self ._vzs is not None and self ._depthshade
625
- else bc
631
+ else color_array
626
632
)
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 ())
630
639
631
640
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.
632
644
if cbook ._str_equal (self ._edgecolors , 'face' ):
633
645
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 ())
644
647
645
648
646
649
def patch_collection_2d_to_3d (col , zs = 0 , zdir = 'z' , depthshade = True ):
0 commit comments