From: W. Trevor King Date: Sat, 21 Jan 2012 18:53:14 +0000 (-0500) Subject: Remove pylab.ion() from plot_image.py's main(). X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=5f88f013cf4f717184e125c48ad539fba5451706;p=parallel_computing.git Remove pylab.ion() from plot_image.py's main(). When pylab is in interactive mode, showing the figures does not halt script exectution. This means that the script will likely complete before the user has time to appreciate the figure (unless the are *really* fast ;)). Also use figure/axes methods where possible (instead of pylab.axes, etc.). It's cleaner that way ;). --- diff --git a/src/plot_image/plot_image.py b/src/plot_image/plot_image.py index 9eaaa20..591a7f4 100755 --- a/src/plot_image/plot_image.py +++ b/src/plot_image/plot_image.py @@ -149,9 +149,9 @@ def plot(X, Y, Z, full=False, title=None, contours=None, cmap=None): fig = pylab.figure() if full: - axes = pylab.axes([0, 0, 1, 1]) + axes = fig.add_axes([0, 0, 1, 1]) else: - axes = pylab.axes() + axes = fig.add_subplot(1, 1, 1) if title: axes.set_title(title) axes.set_axis_off() @@ -159,7 +159,7 @@ def plot(X, Y, Z, full=False, title=None, contours=None, cmap=None): if contours: cset = axes.contour(X[:-1,:-1], Y[:-1,:-1], Z, contours, cmap=cmap) # [:-1,:-1] to strip dummy last row & column from X&Y. - pylab.clabel(cset, inline=1, fmt='%1.1f', fontsize=10) + axes.clabel(cset, inline=1, fmt='%1.1f', fontsize=10) else: # pcolor() is much slower than imshow. #plot = axes.pcolor(X, Y, Z, cmap=cmap, edgecolors='none') @@ -279,7 +279,6 @@ def main(argv=None): if options.output: fig.savefig(options.output) else: - pylab.ion() pylab.show()