aspect in imshow

Hi John, sorry to bother you about this again, but is there

    > a fix to the bug in the imshow routine (using the
    > aspect='preserve' option). If not, let me know if you have
    > an idea when this could be done (no pushing there, just to
    > plan things on my side: I am at the moment using an
    > artificial way to replace that option by calculating
    > coordinates on the plot, just to know if I need to go on
    > with that or not).

Hi Eric, there is not a fix yet, but there is a workaround in CVS.

I played around with some things that got the initial coords right but
then broke under window resizes and I rolled these changes back. It
is a somewhat tough problem, to preserve aspect ration under possible
figure and axes resizes, and/or view limit navigation. It is a very
high priority bug for me, but because it is also a hard one its taking
a little while. SO I can't give you a firm date -- I'll try and get
something serviceable in the next couple of weeks.

This is the same bug that causes zoom to rect on aspect=preserve plots
to get the wrong limits.

Fernando Perez submitted a patch in CVS that works around the problem
for now using the "matshow" command. This command takes the same
arguments as imshow and creates a figure and an axes which are scaled
to have the same dimensions as the array. Thus if you don't resize
your window, you can plot an array with matshow with either free or
preserve and the aspect ratio will be correct. But, if you zoom to
rect or resize your window, even with matshow you'll lose the aspect
ratio. I'll include the docstring for matshow below so you can see if
you're interested

I've very aware of the scientists need to "just see the data" w/o any
fancy stuff. Hopefully a fix will be in soon.



    """Display an array as a matrix.

    The origin is set at the upper left hand corner and rows (first dimension
    of the array) are displayed horizontally. The aspect ratio of the figure
    window is that of the array, as long as it is possible to fit it within
    the constraints of your figure.figsize_min/max parameters with no
    stretching. If the window dimensions can't accomodate this (extremely
    tall/wide arrays), some stretching will inevitably occur.

    matshow() calls imshow() with args and **kwargs, but by default
    it sets interpolation='nearest' (unless you override it). All
    other arguments and keywords are passed to imshow(), so see its
    docstring for further details.

    Tick labels for the xaxis are placed on top by default.
    return value is a (fig, ax, im) tuple

    Example usage:
    def samplemat(dims):
        aa = zeros(dims)
        for i in range(min(dims)):
            aa[i,i] = i
        return aa

    dimlist = [(12,12),(128,64),(64,512),(2048,256)]

    for d in dimlist:
        fig, ax, im = matshow(samplemat(d))