32
32
import matplotlib .image as mimage
33
33
from matplotlib .artist import allow_rasterization
34
34
35
-
36
35
from matplotlib .cbook import iterable
37
36
37
+ from matplotlib import is_interactive
38
+
38
39
39
40
is_string_like = cbook .is_string_like
40
41
is_sequence_of_strings = cbook .is_sequence_of_strings
@@ -442,6 +443,7 @@ def __init__(self, fig, rect,
442
443
self .set_cursor_props ((1 , 'k' )) # set the cursor properties for axes
443
444
444
445
self ._cachedRenderer = None
446
+ self ._in_outer_method = False
445
447
self .set_navigate (True )
446
448
self .set_navigate_mode (None )
447
449
@@ -461,6 +463,40 @@ def __init__(self, fig, rect,
461
463
self ._ycid = self .yaxis .callbacks .connect ('units finalize' ,
462
464
self .relim )
463
465
466
+
467
+ def draw_if_interactive (self , outer = False ):
468
+ print ("entering draw_if_interactive in axes/_base, outer = " , outer )
469
+ # Not sure whether this should be public or private...
470
+ if not outer or not is_interactive ():
471
+ return False
472
+ # Leave out the following check for now; it probably
473
+ # has to be modified so that it does not require importing
474
+ # all the available interactive backends just to make
475
+ # the list of canvases. Instead, the check could be based
476
+ # on the str() or (repr) of self.canvas.
477
+ #if not isinstance(self.canvas, interactive_canvases):
478
+ # return
479
+ self .figure .canvas .draw ()
480
+ print ("drawing complete in axes/_base" )
481
+ return True
482
+
483
+ def check_interactive (self ):
484
+ """
485
+ Return True upon entering an outer method, and set the
486
+ flag; return False if already in an outer method.
487
+ """
488
+ if not self ._in_outer_method :
489
+ self ._in_outer_method = True
490
+ print ("checking: toggled _in_outer_method to True" )
491
+ return True
492
+ print ("checking: already _in_outer_method; returning False" )
493
+ return False
494
+
495
+ def clear_interactive (self , drawn ):
496
+ if drawn :
497
+ self ._in_outer_method = False
498
+
499
+
464
500
def __setstate__ (self , state ):
465
501
self .__dict__ = state
466
502
# put the _remove_method back on all artists contained within the axes
0 commit comments