contour extent

Hi all.

I have 2 issues with the contour routine. I'm just giving it a 2D array. The first issue which is not a show stopper, is that, it uses j for the x position and i for the y-position (where my data is given by: M[i][j]). This seems counter intuitive. Can I switch the convention without transposing all the data?

The other issue seems more difficult. It seems to be ignoring any "extent=" options I give it. Is this because I just supplied a single 2D array rather than also supplying spatial x,y values too?

Thanks,
Craig

Craig,

Craig Maloney wrote:

Hi all.

I have 2 issues with the contour routine. I'm just giving it a 2D array. The first issue which is not a show stopper, is that, it uses j for the x position and i for the y-position (where my data is given by: M[i][j]). This seems counter intuitive. Can I switch the convention without transposing all the data?

No, you have to transpose the data. I could put in an option to determine this orientation, but I am not inclined to do so now. The present orientation follows Matlab, and is present in related functions such as imshow and pcolor. I presume the original rationale was to make everything follow the convention that just as a row of the array is printed from left to right, it should correspond to the x-axis of the plot. I agree that this conflicts with the alternative convention (i,j) -> (x,y) that one might equally well expect, however.

The other issue seems more difficult. It seems to be ignoring any "extent=" options I give it. Is this because I just supplied a single 2D array rather than also supplying spatial x,y values too?

No, I don't think so. Have you looked at the examples/contour_image.py? It illustrates the use of extent, as well as the way in which imshow and contour are designed to be compatible.

Eric