Routine to show matrices?

Hi all,

one of the things which has been bugging me in my recent conversion to mpl has been the lack of a good matrix display routine, which would plot the arrays with 'upper' origin but row-descending numbers, and which would satisfy the colliding constraints of no stretching, a window with the aspect ratio of the original array, all within reasonable window sizes.

imshow, figimage and pcolor all fail to do this in different ways. So I'm attaching here a new routine, which roughly does what I want (with current CVS code, since it needs my new figure() patch). I called it matshow, for lack of a better name. If you run the attached script via %run in a pylab session, it will display various arrays.

I think the functionality is a good improvement over the existing image-related display routines (I need something like this from day 1 if I'm to use matplotlib), but I have some doubts about my implementation. I poked around inside matplotlib for a while, trying to finesse this functionality into imshow() itself, but I got hopelessly lost. Perhaps a better coder than me can make it work, if y'all think the functionality is worth having.

If people don't mind the implementation, I guess I'd like to see it included (perhaps with a better name, and after a good review by the experts). The docstring contains some notes about improvements I don't know how to make, and the code is heavily commented.

Regards,

f

matshow.py (2.59 KB)

Quoting Fernando Perez <Fernando.Perez@...76...>:

a better name. If you run the attached script via %run in a pylab session,
it will display various arrays.

I just tested this code on a second box with different mpl defaults and found a
few minor issues. They are now fixed in this new attached version.

Regards,

f

matshow.py (3.12 KB)