question about imshow

Hi, I'm struggling to get an array plotted the way I want with imshow.
I have an array A which i try to plot with

e=(tdims[0], tdims[-1], wldims[-1], wldims[0])
imshow(A,extent=e)

The image displays fine in the x axis, with tdims marked correctly,
but in the yaxis the dimensions are incorrect. And no combination of
extent and origin gives the correect display. To be more clear,
without extent set I get the array displayed the right way round, but
my problem is that my y axis should be *decreasing* as it goes up the
side of the image; if I set extent correctly, the image is scaled
right with respect to the y axis, but it is flipped so that the y axis
is increasing upwards. Is there a way to prevent this?

Many thanks for any help!
Ans thanks for an excellent plotting library!

Best regards
John

MMh. You can always play with the limits on the y axis:

gca().set_ylim(N.asarray(gca().get_ylim())[[-1,0]])

will invert (ymin, ymax) on the current axis (gca())

···

On Tuesday 12 December 2006 06:57, John Travers wrote:

Hi, I'm struggling to get an array plotted the way I want with imshow.
I have an array A which i try to plot with

e=(tdims[0], tdims[-1], wldims[-1], wldims[0])
imshow(A,extent=e)

if I set extent correctly, the image is scaled
right with respect to the y axis, but it is flipped so that the y axis
is increasing upwards. Is there a way to prevent this?

Thanks for your answers!
Pierre's method worked (I didn't try Scott's).
Cheers,
John

···

On 12/12/06, Pierre GM <pgmdevlist@...287...> wrote:

On Tuesday 12 December 2006 06:57, John Travers wrote:
> Hi, I'm struggling to get an array plotted the way I want with imshow.
> I have an array A which i try to plot with
>
> e=(tdims[0], tdims[-1], wldims[-1], wldims[0])
> imshow(A,extent=e)
>
> if I set extent correctly, the image is scaled
> right with respect to the y axis, but it is flipped so that the y axis
> is increasing upwards. Is there a way to prevent this?

MMh. You can always play with the limits on the y axis:

gca().set_ylim(N.asarray(gca().get_ylim())[[-1,0]])

will invert (ymin, ymax) on the current axis (gca())

This slightly modified excerpt from the new version of spy may do what you want:

nr, nc = Z.shape
extent = [-0.5, nc-0.5, nr-0.5, -0.5]
return self.imshow(Z, interpolation='nearest',
                        extent=extent, origin='upper')

Eric

John Travers wrote:

···

Hi, I'm struggling to get an array plotted the way I want with imshow.
I have an array A which i try to plot with

e=(tdims[0], tdims[-1], wldims[-1], wldims[0])
imshow(A,extent=e)

The image displays fine in the x axis, with tdims marked correctly,
but in the yaxis the dimensions are incorrect. And no combination of
extent and origin gives the correect display. To be more clear,
without extent set I get the array displayed the right way round, but
my problem is that my y axis should be *decreasing* as it goes up the
side of the image; if I set extent correctly, the image is scaled
right with respect to the y axis, but it is flipped so that the y axis
is increasing upwards. Is there a way to prevent this?

Many thanks for any help!
Ans thanks for an excellent plotting library!

Best regards
John

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users