imshow seems to fail on some (int16?) arrays

Antony Lee <antony.lee@...83...> writes:

I'm trying to plot a grayscale (nonzero) array as an image -- so it's

basically
plt.imshow(array). However, this pops up (after plt.show()) a completely black
image. It happens that this array has dtype=int16, and imshow's doc says that
it
only accepts float arrays, though I'm pretty sure it does some conversion to
allow int32s (at least, as I've used them before). So I tried plt.imshow
(asarray
(array, dtype=np.dtype(np.int32))), and it worked (the image showed up). With
asfarray(array), it worked too. Now, the weirdest part was that though np.abs
(array) or abs(array) (the builtin abs) still have dtype int16, they can be
plotted successfully with plt.imshow too!

So I must say I'm not really sure of what's failing here... has anyone

encountered this bug before?

The following works for me with IPython 0.10 in -pylab mode with
Python 2.6.4 on Windows XP. Unfortunately, I'm not sure what the
default graphics backend is.

# pylab mode automatically imports imshow()
import numpy as np
a = np.eye(4, dtype=np.int16)
imshow(a) # red blurred squares on blue background
imshow(a, interpolation="nearest") # sharp squares

Could you please give a simple, self-contained, reproducible code example
that produces your problem?

Hope this helps,
Jon Olav