From: W. Trevor King Date: Thu, 7 Feb 2013 06:01:25 +0000 (-0500) Subject: Standardize matplotlib rendering on figure.canvas.draw() and figure.show(). X-Git-Tag: v0.2~11 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=3afbb2f9d48a8fb665db2413f1ce2f7f2cacff38;p=unfold-protein.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/unfold_protein/unfolder.py b/unfold_protein/unfolder.py index 5a82716..57def43 100755 --- a/unfold_protein/unfolder.py +++ b/unfold_protein/unfolder.py @@ -33,6 +33,7 @@ from . import package_config as _package_config try: import numpy as _numpy + import matplotlib as _matplotlib from matplotlib import pyplot as _pyplot _pyplot.ion() FIGURE = _pyplot.figure() @@ -118,7 +119,11 @@ class Unfolder (object): axes = FIGURE.add_subplot(1, 1, 1) axes.plot(data['z'], data['deflection'], label='Approach') axes.set_title('Unfolding too far') - _pyplot.show() + FIGURE.canvas.draw() + if hasattr(FIGURE, 'show'): + FIGURE.show() + if not _matplotlib.is_interactive(): + _pyplot.show() _LOG.debug('raising ExceptionTooFar') raise ExceptionTooFar return data @@ -233,8 +238,11 @@ class Unfolder (object): axes.plot(unfold['z'], unfold['deflection'], label='Unfold') axes.legend(loc='best') axes.set_title('Unfolding') - _pyplot.draw() - _pyplot.show() + FIGURE.canvas.draw() + if hasattr(FIGURE, 'show'): + FIGURE.show() + if not _matplotlib.is_interactive(): + _pyplot.show() def zero_piezo(self): _LOG.info('zero piezo')