./plot_image.py --help
When run with interactive output (i.e. no `-o ...` option), the
-interactive figure is displayed using `pylab.show`, which means that
+interactive figure is displayed using `pyplot.show`, which means that
you'll have to kill `plot_image.py` using ^C or similar [1]_.
For other ideas, see the Matplotlib website [2]_.
import sys
import matplotlib
+import matplotlib.cm
import matplotlib.image
import numpy
# Depending on your Matplotlib configuration, you may need to adjust
-# your backend. Do this before importing pylab or matplotlib.backends.
+# your backend. Do this before importing pylab, matplotlib.pyplot, or
+# matplotlib.backends.
#matplotlib.use('Agg') # select backend that doesn't require X Windows
-#matplotlib.use('GTKAgg') # select backend that supports pylab.show()
+#matplotlib.use('GTKAgg') # select backend that supports pyplot.show()
# Alternatively, you can configure the backend using
# ~/.matplotlib/matplotlibrc:
# backend : Agg
# #backend : GTKAgg
-import pylab
+import matplotlib.pyplot
_DOC = __doc__
array([[ 0., 1., 2., 3., 4.],
[ 5., 6., 7., 8., 9.]])
"""
- X,Y = pylab.meshgrid(range(nx+1), range(ny+1))
+ X,Y = numpy.meshgrid(range(nx+1), range(ny+1))
Z = numpy.loadtxt(stream)
assert Z.size == nx*ny, 'Z.size = %d != %d = %dx%d' % (
Z.size, nx*ny, nx, ny)
dy = Ys[-1] - Ys[-2]
Xs = numpy.append(Xs, Xs[-1] + dx)
Ys = numpy.append(Ys, Ys[-1] + dy)
- X,Y = pylab.meshgrid(Xs, Ys)
+ X,Y = numpy.meshgrid(Xs, Ys)
return (X,Y,Z)
def plot(X, Y, Z, full=False, title=None, contours=None, interpolation=None,
cmap=None):
"""Plot Z over the mesh X, Y.
- >>> X, Y = pylab.meshgrid(range(6), range(2))
+ >>> X, Y = numpy.meshgrid(range(6), range(2))
>>> Z = X[:-1,:-1]**2 + Y[:-1,:-1]
>>> plot(X, Y, Z) # doctest: +ELLIPSIS
<matplotlib.figure.Figure object at 0x...>
Y_min = Y[0,0]
Y_max = Y[-1,-1]
- fig = pylab.figure()
+ fig = matplotlib.pyplot.figure()
if full:
axes = fig.add_axes([0, 0, 1, 1])
else:
p.add_option('--interpolation', dest='interpolation', default='nearest',
help=('Interpolation scheme (for false color images) from %s '
'(%%default)') % ', '.join(interpolations))
- maps=[m for m in pylab.cm.datad if not m.endswith("_r")]
+ maps=[m for m in matplotlib.cm.datad if not m.endswith("_r")]
maps.sort()
p.add_option('-m', '--color-map', dest='cmap', default='jet',
help='Select color map from %s (%%default)' % ', '.join(maps))
nx,ny = [int(x) for x in options.size.split(',')]
try:
- cmap = getattr(pylab.cm, options.cmap)
+ cmap = getattr(matplotlib.cm, options.cmap)
except AttributeError:
raise Exception('no color map named %s in %s'
% (options.cmap, ', '.join(maps)))
if options.output:
fig.savefig(options.output)
else:
- pylab.show()
+ matplotlib.pyplot.show()
if __name__ == '__main__':