@@ -819,18 +819,26 @@ def do_3d_projection(self):
819819 return np .nan
820820
821821 def _maybe_depth_shade_and_sort_colors (self , color_array ):
822- color_array = (
823- _zalpha (
822+ # Adjust the color_array alpha values if point depths are defined
823+ # and depth shading is active
824+ alpha = self ._alpha
825+ if self ._vzs is not None and self ._depthshade :
826+ color_array = _zalpha (
824827 color_array ,
825828 self ._vzs ,
826829 min_alpha = self ._depthshade_minalpha ,
827830 )
828- if self ._vzs is not None and self ._depthshade
829- else color_array
830- )
831+ if alpha is not None and color_array .shape [1 ] == 4 : # RGBA, not RGB
832+ alpha = alpha * color_array [:, 3 ]
833+
834+ # Adjust the order of the color_array using the _z_markers_idx,
835+ # which has been sorted by z-depth
831836 if len (color_array ) > 1 :
832837 color_array = color_array [self ._z_markers_idx ]
833- return mcolors .to_rgba_array (color_array , self ._alpha )
838+ if np .ndim (alpha ) > 0 :
839+ alpha = np .asarray (alpha )[self ._z_markers_idx ]
840+
841+ return mcolors .to_rgba_array (color_array , alpha )
834842
835843 def get_facecolor (self ):
836844 return self ._maybe_depth_shade_and_sort_colors (super ().get_facecolor ())
@@ -1070,20 +1078,25 @@ def _use_zordered_offset(self):
10701078 def _maybe_depth_shade_and_sort_colors (self , color_array ):
10711079 # Adjust the color_array alpha values if point depths are defined
10721080 # and depth shading is active
1081+ alpha = self ._alpha
10731082 if self ._vzs is not None and self ._depthshade :
10741083 color_array = _zalpha (
10751084 color_array ,
10761085 self ._vzs ,
10771086 min_alpha = self ._depthshade_minalpha ,
10781087 _data_scale = self ._data_scale ,
10791088 )
1089+ if alpha is not None and color_array .shape [1 ] == 4 : # RGBA, not RGB
1090+ alpha = alpha * color_array [:, 3 ]
10801091
10811092 # Adjust the order of the color_array using the _z_markers_idx,
10821093 # which has been sorted by z-depth
10831094 if len (color_array ) > 1 :
10841095 color_array = color_array [self ._z_markers_idx ]
1096+ if np .ndim (alpha ) > 0 :
1097+ alpha = np .asarray (alpha )[self ._z_markers_idx ]
10851098
1086- return mcolors .to_rgba_array (color_array )
1099+ return mcolors .to_rgba_array (color_array , alpha )
10871100
10881101 def get_facecolor (self ):
10891102 return self ._maybe_depth_shade_and_sort_colors (super ().get_facecolor ())
0 commit comments