From 311c82f57aa471e7e9cd1aa041e789280f43a539 Mon Sep 17 00:00:00 2001 From: Damon McDougall Date: Sun, 7 Oct 2012 18:56:51 +0100 Subject: [PATCH 1/2] Add poor man version of improved OO --- lib/matplotlib/figure.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/matplotlib/figure.py b/lib/matplotlib/figure.py index 798cd661fc1e..fba5f52d0eb9 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. From f75cdb00137524607a21794b7b79a17b0b8ef1f0 Mon Sep 17 00:00:00 2001 From: Damon McDougall Date: Wed, 7 Nov 2012 18:38:23 -0600 Subject: [PATCH 2/2] Add update method for refreshing with OO-ness --- lib/matplotlib/figure.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/matplotlib/figure.py b/lib/matplotlib/figure.py index fba5f52d0eb9..fce646eb0fdb 100644 --- a/lib/matplotlib/figure.py +++ b/lib/matplotlib/figure.py @@ -368,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()