@@ -44,10 +44,6 @@ def draw(self, renderer: RendererBase):
4444 self ._artist .set_clip_box (clip_box_orig )
4545
4646
47- class SharedRenderDepth :
48- current_depth = 0
49-
50-
5147def view_wrapper (axes_class : Type [Axes ]) -> Type [Axes ]:
5248 """
5349 Construct a ViewAxes, which subclasses, or wraps a specific Axes subclass.
@@ -146,6 +142,9 @@ def _init_vars(
146142 raise ValueError (f"The filter function must be a callable!" )
147143
148144 self .__view_axes = axes_to_view
145+ self .figure ._current_render_depth = getattr (
146+ self .figure , "_current_render_depth" , 0
147+ )
149148 self .__image_interpolation = image_interpolation
150149 self .__max_render_depth = render_depth
151150 self .__filter_function = filter_function
@@ -186,9 +185,9 @@ def draw(self, renderer: RendererBase = None):
186185 # It is possible to have two axes which are views of each other
187186 # therefore we track the number of recursions and stop drawing
188187 # at a certain depth
189- if (SharedRenderDepth . current_depth >= self .__max_render_depth ):
188+ if (self . figure . _current_render_depth >= self .__max_render_depth ):
190189 return
191- SharedRenderDepth . current_depth += 1
190+ self . figure . _current_render_depth += 1
192191 # Set the renderer, causing get_children to return the view's
193192 # children also...
194193 self .__renderer = renderer
@@ -197,7 +196,7 @@ def draw(self, renderer: RendererBase = None):
197196
198197 # Get rid of the renderer...
199198 self .__renderer = None
200- SharedRenderDepth . current_depth -= 1
199+ self . figure . _current_render_depth -= 1
201200
202201 def get_linescaling (self ) -> bool :
203202 """
0 commit comments