1
1
import itertools
2
- from typing import Type , List , Optional , Callable
2
+ from typing import Type , List , Optional , Callable , Any
3
3
from matplotlib .axes import Axes
4
4
from matplotlib .transforms import Bbox
5
5
import matplotlib .docstring as docstring
9
9
10
10
DEFAULT_RENDER_DEPTH = 5
11
11
12
- class BoundRendererArtist :
12
+ class _BoundRendererArtist :
13
13
def __init__ (
14
14
self ,
15
15
artist : Artist ,
@@ -20,13 +20,13 @@ def __init__(
20
20
self ._renderer = renderer
21
21
self ._clip_box = clip_box
22
22
23
- def __getattribute__ (self , item ) :
23
+ def __getattribute__ (self , item : str ) -> Any :
24
24
try :
25
25
return super ().__getattribute__ (item )
26
26
except AttributeError :
27
27
return self ._artist .__getattribute__ (item )
28
28
29
- def __setattr__ (self , key , value ):
29
+ def __setattr__ (self , key : str , value : Any ):
30
30
try :
31
31
super ().__setattr__ (key , value )
32
32
except AttributeError :
@@ -36,8 +36,11 @@ def draw(self, renderer: RendererBase):
36
36
# Disable the artist defined clip box, as the artist might be visible
37
37
# under the new renderer even if not on screen...
38
38
clip_box_orig = self ._artist .get_clip_box ()
39
+ clip_path_orig = self ._artist .get_clip_path ()
40
+
39
41
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 )
41
44
42
45
# If we are working with a 3D object, swap out it's axes with
43
46
# this zoom axes (swapping out the 3d transform) and reproject it.
@@ -49,16 +52,21 @@ def draw(self, renderer: RendererBase):
49
52
if (Bbox .intersection (full_extents , self ._clip_box ) is not None ):
50
53
self ._artist .draw (self ._renderer )
51
54
52
- # Re-enable the clip box...
55
+ # Re-enable the clip box... and clip path...
53
56
self ._artist .set_clip_box (clip_box_orig )
57
+ self ._artist .set_clip_path (clip_path_orig )
54
58
55
- def do_3d_projection (self ):
59
+ def do_3d_projection (self ) -> float :
60
+ # Get the 3D projection function...
56
61
do_3d_projection = getattr (self ._artist , "do_3d_projection" )
57
62
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.
58
66
ax = self ._artist .axes
59
- self ._artist .axes = None
67
+ self ._artist .axes = None # Set to None first to avoid exception...
60
68
self ._artist .axes = self ._renderer .bounding_axes
61
- res = do_3d_projection ()
69
+ res = do_3d_projection () # Returns a z-order value...
62
70
self ._artist .axes = None
63
71
self ._artist .axes = ax
64
72
@@ -195,9 +203,10 @@ def get_children(self) -> List[Artist]:
195
203
196
204
init_list = super ().get_children ()
197
205
init_list .extend ([
198
- BoundRendererArtist (a , mock_renderer , axes_box )
206
+ _BoundRendererArtist (a , mock_renderer , axes_box )
199
207
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
201
210
) if (self .__filter_function (a ))
202
211
])
203
212
0 commit comments