diff --git a/lib/matplotlib/figure.py b/lib/matplotlib/figure.py index 798cd661fc1e..fce646eb0fdb 100644 --- a/lib/matplotlib/figure.py +++ b/lib/matplotlib/figure.py @@ -318,7 +318,6 @@ def __init__(self, self.patch.set_aa(False) self._hold = rcParams['axes.hold'] - self.canvas = None if subplotpars is None: subplotpars = SubplotParams() @@ -327,9 +326,17 @@ def __init__(self, self.set_tight_layout(tight_layout) self._axstack = AxesStack() # track all figure axes and current axes + self._axobservers = [] + self.canvas = self._setup_canvas() self.clf() self._cachedRenderer = None + def _setup_canvas(self): + import matplotlib.backends as mbackends + backend_mod, _, _, _ = mbackends.pylab_setup() + manager = backend_mod.new_figure_manager_given_figure(1, self) + return manager.canvas + def show(self, warn=True): """ If using a GUI backend with pyplot, display the figure window. @@ -361,6 +368,9 @@ def show(self, warn=True): "matplotlib is currently using a non-GUI backend, " "so cannot show the figure") + def update(self): + self.canvas.draw_idle() + def _get_axes(self): return self._axstack.as_list()