Only call figure.show if it exits.
authorW. Trevor King <wking@tremily.us>
Thu, 2 Aug 2012 16:19:48 +0000 (12:19 -0400)
committerW. Trevor King <wking@tremily.us>
Thu, 2 Aug 2012 16:19:48 +0000 (12:19 -0400)
For example, figures generated with the Agg backend don't have a
'show' method.

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

index 7e840f61296701ee9a0bdd7d29521b50b1d39942..6e00347a26e6f2195148407750a1c5ee919ff8a4 100644 (file)
@@ -260,7 +260,8 @@ class AFMPiezo (_base.Piezo):
             axes.plot(pos_array, def_array, '.', label=timestamp)
             #_pylab.legend(loc='best')
             figure.canvas.draw()
-            figure.show()
+            if hasattr(figure, 'show'):
+                figure.show()
             if not _matplotlib.is_interactive():
                 _matplotlib_pyplot.show()
 
index 55ec00b7b7aa4fbb2b222ca488c34053cba991be..3220e21833a060eca3eb76d2a03e0dd695ed6ba8 100644 (file)
@@ -900,7 +900,8 @@ class Piezo (object):
                 for i,name in enumerate(names):
                     axes.plot(d[:,i], label=name)
             figure.canvas.draw()
-            figure.show()
+            if hasattr(figure, 'show'):
+                figure.show()
             if not _matplotlib.is_interactive():
                 _matplotlib_pyplot.show()
         return input_data
index fe096bb89ccb6d806fe6a31295efe7facfcce3dd..6443ea29a5e4562a760e3301239c8a102737dd22 100644 (file)
@@ -236,7 +236,8 @@ def analyze_surface_position_data(
                    fit_fn(final_pos, params)], '-',label='fit')
         #_pylab.legend(loc='best')
         figure.canvas.draw()
-        figure.show()
+        if hasattr(figure, 'show'):
+            figure.show()
         if not _matplotlib.is_interactive():
             _matplotlib_pyplot.show()
 
index 6067ffa6e897e46fe83116d248274561700fa0cf..1f0d705a79807ee601a0852c403551c2cf076f9a 100644 (file)
@@ -138,7 +138,8 @@ def _setup_plot(piezo, config, output):
     axes.set_title('wiggle for interference %s' % timestamp)
     plot = axes.plot(output, output, 'b.-')
     figure.canvas.draw()
-    figure.show()
+    if hasattr(figure, 'show'):
+        figure.show()
     if not _matplotlib.is_interactive():
         _matplotlib_pyplot.show()
     return (figure, axes, plot)