11import itertools
2- from typing import Type , List , Optional , Callable
2+ from typing import Type , List , Optional , Callable , Any
33from matplotlib .axes import Axes
44from matplotlib .transforms import Bbox
55import matplotlib .docstring as docstring
99
1010DEFAULT_RENDER_DEPTH = 5
1111
12- class BoundRendererArtist :
12+ class _BoundRendererArtist :
1313 def __init__ (
1414 self ,
1515 artist : Artist ,
@@ -20,13 +20,13 @@ def __init__(
2020 self ._renderer = renderer
2121 self ._clip_box = clip_box
2222
23- def __getattribute__ (self , item ) :
23+ def __getattribute__ (self , item : str ) -> Any :
2424 try :
2525 return super ().__getattribute__ (item )
2626 except AttributeError :
2727 return self ._artist .__getattribute__ (item )
2828
29- def __setattr__ (self , key , value ):
29+ def __setattr__ (self , key : str , value : Any ):
3030 try :
3131 super ().__setattr__ (key , value )
3232 except AttributeError :
@@ -36,8 +36,11 @@ def draw(self, renderer: RendererBase):
3636 # Disable the artist defined clip box, as the artist might be visible
3737 # under the new renderer even if not on screen...
3838 clip_box_orig = self ._artist .get_clip_box ()
39+ clip_path_orig = self ._artist .get_clip_path ()
40+
3941 full_extents = self ._artist .get_window_extent (self ._renderer )
40- self ._artist .set_clip_box (full_extents )
42+ self ._artist .set_clip_box (None )
43+ self ._artist .set_clip_path (None )
4144
4245 # If we are working with a 3D object, swap out it's axes with
4346 # this zoom axes (swapping out the 3d transform) and reproject it.
@@ -49,16 +52,21 @@ def draw(self, renderer: RendererBase):
4952 if (Bbox .intersection (full_extents , self ._clip_box ) is not None ):
5053 self ._artist .draw (self ._renderer )
5154
52- # Re-enable the clip box...
55+ # Re-enable the clip box... and clip path...
5356 self ._artist .set_clip_box (clip_box_orig )
57+ self ._artist .set_clip_path (clip_path_orig )
5458
55- def do_3d_projection (self ):
59+ def do_3d_projection (self ) -> float :
60+ # Get the 3D projection function...
5661 do_3d_projection = getattr (self ._artist , "do_3d_projection" )
5762
63+ # Intentionally replace the axes of the artist with the view axes,
64+ # as the do_3d_projection pulls the 3D transform (M) from the axes.
65+ # Then reproject, and restore the original axes.
5866 ax = self ._artist .axes
59- self ._artist .axes = None
67+ self ._artist .axes = None # Set to None first to avoid exception...
6068 self ._artist .axes = self ._renderer .bounding_axes
61- res = do_3d_projection ()
69+ res = do_3d_projection () # Returns a z-order value...
6270 self ._artist .axes = None
6371 self ._artist .axes = ax
6472
@@ -195,9 +203,10 @@ def get_children(self) -> List[Artist]:
195203
196204 init_list = super ().get_children ()
197205 init_list .extend ([
198- BoundRendererArtist (a , mock_renderer , axes_box )
206+ _BoundRendererArtist (a , mock_renderer , axes_box )
199207 for a in itertools .chain (
200- self .__view_axes ._children , self .__view_axes .child_axes
208+ self .__view_axes ._children ,
209+ self .__view_axes .child_axes
201210 ) if (self .__filter_function (a ))
202211 ])
203212
0 commit comments