Standardize matplotlib rendering on figure.canvas.draw() and figure.show().
authorW. Trevor King <wking@tremily.us>
Thu, 12 Jul 2012 22:18:08 +0000 (18:18 -0400)
committerW. Trevor King <wking@tremily.us>
Thu, 12 Jul 2012 22:23:58 +0000 (18:23 -0400)
In interactive mode, skip the no-op pyplot.show().  In non-interactive
mode, the show() calls will block until the window is closed.

pypiezo/afm.py
pypiezo/base.py
pypiezo/surface.py
pypiezo/wiggle.py

index c392c62f2df4f020dace0f4e011c89da994718d9..7e840f61296701ee9a0bdd7d29521b50b1d39942 100644 (file)
@@ -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 = {
index d049faa5e741b22df979a426bc4b890b1233af43..55ec00b7b7aa4fbb2b222ca488c34053cba991be 100644 (file)
@@ -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=()):
index 3d59cf2dc5256f5634f6574e5fa1ba6da3edcbaf..a0f9055e2cacb8f098fd43315a6a2aab3134a36a 100644 (file)
@@ -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
index 95e287174817d24766e78e3fc9de6f15c46dacdb..6067ffa6e897e46fe83116d248274561700fa0cf 100644 (file)
@@ -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):