def scaledimage(W, pixwidth=1, ax=None, grayscale=True):
"""
Do intensity plot, similar to MATLAB imagesc()
W = intensity matrix to visualize
pixwidth = size of each W element
ax = matplotlib Axes to draw on
grayscale = use grayscale color map
Rely on caller to .show()
"""
# N = rows, M = column
(N, M) = W.shape
# Need to create a new Axes?
if(ax == None):
ax = plt.figure().gca()
# extents = Left Right Bottom Top
exts = (0, pixwidth * M, 0, pixwidth * N)
if(grayscale):
ax.imshow(W,
interpolation='nearest',
cmap=CM.gray,
extent=exts)
else:
ax.imshow(W,
interpolation='nearest',
extent=exts)
ax.xaxis.set_major_locator(MT.NullLocator())
ax.yaxis.set_major_locator(MT.NullLocator())
return ax
评论列表
文章目录