When using imshow(), why does there always seem to be a
> blank zone along the southern and eastern edges of the
> figure? For instance:
> X = rand(10,10) imshow(X)
> plots a luminance image of X, which seems fine, except
> for the lower and rightmost edges, which are blank. I
> may be misunderstanding the purpose of imshow, but
> skimming through the code didn't give me an answer. I
> am using matplotlib 0.52 on WinXP with either GTKAgg or
> TkAgg.
Hi Dominique,
Your example did point me to a small bug in the image module, but it
is mostly unrelated to what you are observing. In the axes.py
function imshow, replace
self.set_image_extent(0, numcols-1, 0, numrows-1)
with
self.set_image_extent(0, numcols, 0, numrows)
This only affects the tick labeling (not the actual image display)
but it was wrong before and should be changed.
Now run this script
from matplotlib.matlab import *
X = rand(10,10)
subplot(211)
im = imshow(X)
im.set_interpolation('nearest')
subplot(212)
im = imshow(X)
show()
The key thing is that the white border you are seeing arises from
interpolation. The points on the bottom and right have no neighbors
in those directions, and so they interpolate to the background color,
which is white.
You can set the axis limits so that these regions don't appear, or use
nearest neighbor interpolation.
Let me know if these suggestions don't work for you.
JDH