From: W. Trevor King Date: Thu, 12 Jul 2012 22:18:08 +0000 (-0400) Subject: Standardize matplotlib rendering on figure.canvas.draw() and figure.show(). X-Git-Tag: 0.7~2 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=e45528302fbeed1d91cd95e9a0b46c870215ecb4;p=pypiezo.git Standardize matplotlib rendering on figure.canvas.draw() and figure.show(). In interactive mode, skip the no-op pyplot.show(). In non-interactive mode, the show() calls will block until the window is closed. --- diff --git a/pypiezo/afm.py b/pypiezo/afm.py index c392c62..7e840f6 100644 --- a/pypiezo/afm.py +++ b/pypiezo/afm.py @@ -259,7 +259,10 @@ class AFMPiezo (_base.Piezo): axes.set_title('step approach %s' % timestamp) axes.plot(pos_array, def_array, '.', label=timestamp) #_pylab.legend(loc='best') + figure.canvas.draw() figure.show() + if not _matplotlib.is_interactive(): + _matplotlib_pyplot.show() if return_data: data = { diff --git a/pypiezo/base.py b/pypiezo/base.py index d049faa..55ec00b 100644 --- a/pypiezo/base.py +++ b/pypiezo/base.py @@ -899,7 +899,10 @@ class Piezo (object): (input_data, input_names)]: for i,name in enumerate(names): axes.plot(d[:,i], label=name) + figure.canvas.draw() figure.show() + if not _matplotlib.is_interactive(): + _matplotlib_pyplot.show() return input_data def named_ramp(self, data, frequency, output_names, input_names=()): diff --git a/pypiezo/surface.py b/pypiezo/surface.py index 3d59cf2..a0f9055 100644 --- a/pypiezo/surface.py +++ b/pypiezo/surface.py @@ -235,7 +235,10 @@ def analyze_surface_position_data( [fit_fn(start_pos, params), fit_fn(params[2], params), fit_fn(final_pos, params)], '-',label='fit') #_pylab.legend(loc='best') + figure.canvas.draw() figure.show() + if not _matplotlib.is_interactive(): + _matplotlib_pyplot.show() # check that the fit is reasonable # params[1] is slope in non-contact region diff --git a/pypiezo/wiggle.py b/pypiezo/wiggle.py index 95e2871..6067ffa 100644 --- a/pypiezo/wiggle.py +++ b/pypiezo/wiggle.py @@ -137,9 +137,10 @@ def _setup_plot(piezo, config, output): timestamp = _time.strftime('%H%M%S') axes.set_title('wiggle for interference %s' % timestamp) plot = axes.plot(output, output, 'b.-') + figure.canvas.draw() figure.show() - _matplotlib_pyplot.draw() - _matplotlib_pyplot.show() + if not _matplotlib.is_interactive(): + _matplotlib_pyplot.show() return (figure, axes, plot) def _update_plot(figure, axes, plot, cycle, data):