Vsevolod Kovalenko wrote:
> Dear matplotlib
> 
> I have a newbie question (I am new to python, migrating from Matlab). Just
> like the subject suggests, I need to display an image X stored in a matrix
> (well, a 2D numpy array in fact) versus the coordinates specified by arrays
> x and y. Further, it would be nice if mouse position was returned in terms
> of those coordinates as well, but that's just for a nicety - I can map it
> myself. But main thing is I failed to find the way to get the image
> versuscoordinates in imshow() and figimage(). I also failed to find the
> answer in this forum.
> 
> Hence I ask for any suggestions.

There is not an *exact* clone of imagesc, but you can certainly get the 
same effect.  Note that imshow has an origin kwarg that lets you specify 
the vertical orientation, and an extent kwarg that controls the mapping 
between pixels and your X and Y scales.  If you want direct indexing 
into a colormap you can get it with the kwarg norm=mpl.colors.NoNorm(), 
provided your Z array has an integer dtype and includes values within 
the range of the colormap; the default colormaps all have 256 colors.

An alternative, if you want to specify the boundaries of the pixels 
rather than their centers (or if you have unevenly-spaced boundaries), 
is pcolor, or pcolormesh.  If you have a recent version of mpl you can 
use the Axes method pcolorfast.

Offhand, though, it sounds like imshow() with suitable kwargs will do 
exactly what you want.  See image_demo2.py in the mpl examples directory.

Eric

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to