Imshow aspect ratio

Hi everyone

Last week I stumbled about a bug in imshow, which can easily be reproduced by doing the following:

python
>>> from pylab import *
>>> imshow(ones((20,40)),aspect='preserve',origin='lower')
>>> show()
Note that the y-axis is wrong and resizing makes this even worse.
I tried versions 0.71 to 0.80 which show all the same behaviour.

It is obviously the aspect='preserve' option, that introduces this bug.

So I'd like to address two issues:
First of course I'd like to ask if this bug could be fixed since constant aspect ratio is very crucial for me.
Second it seems that the plotting area is always maximum size and the aspect='preserve' option just rescales the axis. I think it would be more natural to rescale the plotting area.

Cheers,
Nikolai

Hi Nikolai,

Nikolai Hlubek wrote:

Last week I stumbled about a bug in imshow, which can easily be
reproduced by doing the following:

python
>>> from pylab import *
>>> imshow(ones((20,40)),aspect='preserve',origin='lower')
>>> show()
Note that the y-axis is wrong and resizing makes this even worse.
I tried versions 0.71 to 0.80 which show all the same behaviour.

It is obviously the aspect='preserve' option, that introduces this bug.

So I'd like to address two issues:
First of course I'd like to ask if this bug could be fixed since
constant aspect ratio is very crucial for me.
Second it seems that the plotting area is always maximum size and the
aspect='preserve' option just rescales the axis. I think it would be
more natural to rescale the plotting area.

You may want to use matshow for this kind of problem, which will try to give you
a figure with the aspect ratio of the array you actually want to display.

As you noticed, the preserve feature is basically broken right now, and there
has been a fair amount of discussion on how to fix it. In the meantime, the
best workaround is to compute figure size and axes aspect rations appropriate
for your image aspect ration using the figure and axes command, which is
basically what matshow does.

Best,

f/jdh