how does imshow() represent numpy array with origin = "lower" keyword ?

Hi. I want to make sure how imshow shows a numpy array as image.

lets say below is our numpy data array where letter represent data values and numbers represent row/col indices.

0 1 2

0 a b c

1 d e f

2 g h i

and lets think imshow’s origin is default upper left.

Now, if we show our data as an image, the orientation of visual representation of data shouldt change,

and seen like below, right?

0 1 2

0 a b c

1 d e f

2 g h i

But if we pass origin=“lower” keyword to imshow, (as in basemap by default);

is this what we expect to see ?

0 1 2
2 g h i

1 d e f

0 a b c

To be clear, does imshow with “lower” keyword value;

1-takes first row of data and put it most bottom,

2-then take second row and put it one row upper from most bottom…etc ?

Thanks.

···


Yasin Selçuk Berber
“Bismillah, her hayrın başıdır.”

Hi Yasin,

Yes, your interpretation looks correct to me. Image coordinates typically have an origin at the upper left and increase downward and to the right. Setting origin='lower' essentially changes imshow to use data coordinates, which typically have an origin at the bottom left and increase upward and to the right.

Do you expect (or get) something different?

Best,

-Tony

···

On Tue, May 29, 2012 at 5:31 AM, Yasin Selçuk Berber <yasinberber@…287…> wrote:

Hi. I want to make sure how imshow shows a numpy array as image.

lets say below is our numpy data array where letter represent data values and numbers represent row/col indices.

0 1 2

0 a b c

1 d e f

2 g h i

and lets think imshow’s origin is default upper left.

Now, if we show our data as an image, the orientation of visual representation of data shouldt change,

and seen like below, right?

0 1 2

0 a b c

1 d e f

2 g h i

But if we pass origin=“lower” keyword to imshow, (as in basemap by default);

is this what we expect to see ?

0 1 2
2 g h i

1 d e f

0 a b c

To be clear, does imshow with “lower” keyword value;

1-takes first row of data and put it most bottom,

2-then take second row and put it one row upper from most bottom…etc ?

Thanks.


Yasin Selçuk Berber
“Bismillah, her hayrın başıdır.”

im getting that result.

but just wanted to know, could “takes first row and put it most bottom…then take second…etc” expression be accepted as harmless or not.

2012/5/30 Tony Yu <tsyu80@…287…>

···

On Tue, May 29, 2012 at 5:31 AM, Yasin Selçuk Berber <yasinberber@…287…> wrote:

Hi. I want to make sure how imshow shows a numpy array as image.

lets say below is our numpy data array where letter represent data values and numbers represent row/col indices.

0 1 2

0 a b c

1 d e f

2 g h i

and lets think imshow’s origin is default upper left.

Now, if we show our data as an image, the orientation of visual representation of data shouldt change,

and seen like below, right?

0 1 2

0 a b c

1 d e f

2 g h i

But if we pass origin=“lower” keyword to imshow, (as in basemap by default);

is this what we expect to see ?

0 1 2
2 g h i

1 d e f

0 a b c

To be clear, does imshow with “lower” keyword value;

1-takes first row of data and put it most bottom,

2-then take second row and put it one row upper from most bottom…etc ?

Thanks.


Yasin Selçuk Berber
“Bismillah, her hayrın başıdır.”

Hi Yasin,

Yes, your interpretation looks correct to me. Image coordinates typically have an origin at the upper left and increase downward and to the right. Setting origin='lower' essentially changes imshow to use data coordinates, which typically have an origin at the bottom left and increase upward and to the right.

Do you expect (or get) something different?

Best,

-Tony


Yasin Selçuk Berber
“Bismillah, her hayrın başıdır.”

Seems to, it depends on the interpretation of the expression :slight_smile:
If you are thinking about data copying, IMO there is no extra copy of
the data compared to any other origin choice. You could also say that
rows of the array are displayed bottom-up for origin='lower' and
top-down for origin='upper'

···

Le jeudi 31 mai 2012 à 09:31 +0300, Yasin Selçuk Berber a écrit :

im getting that result.
but just wanted to know, could "takes first row and put it most
bottom....then take second....etc" expression be accepted as harmless or
not.