please document imshow axes order

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

please document imshow axes order

Neal Becker
I just wasted quite a bit of time trying to debug my code.  It took a long
time because I was using imshow to debug, and didn't know that imshow
displays a matrix not using cartesian coordinates.  The axes are transposed
and one axis is reversed.  The documentation doesn't mention this.

Thanks,
Neal

_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users
Reply | Threaded
Open this post in threaded view
|

Re: please document imshow axes order

Nathan Goldbaum
This is discussed in the description of the "origin" keyword argument:

origin : {'upper', 'lower'}, optional

Place the [0,0] index of the array in the upper left or lower left corner of the axes. The convention 'upper' is typically used for matrices and images. If not given, rcParams["image.origin"] is used, defaulting to 'upper'.

Note that the vertical axes points upward for 'lower' but downward for 'upper'.


On Thu, Jun 6, 2019 at 9:25 AM Neal Becker <[hidden email]> wrote:
I just wasted quite a bit of time trying to debug my code.  It took a long
time because I was using imshow to debug, and didn't know that imshow
displays a matrix not using cartesian coordinates.  The axes are transposed
and one axis is reversed.  The documentation doesn't mention this.

Thanks,
Neal

_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users

_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users
Reply | Threaded
Open this post in threaded view
|

Re: please document imshow axes order

Neal Becker
The origin only discusses the inversion of the y axis - in addition
the x-y are transposed.

On Thu, Jun 6, 2019 at 9:30 AM Nathan Goldbaum <[hidden email]> wrote:

>
> This is discussed in the description of the "origin" keyword argument:
>
> origin : {'upper', 'lower'}, optional
>
> Place the [0,0] index of the array in the upper left or lower left corner of the axes. The convention 'upper' is typically used for matrices and images. If not given, rcParams["image.origin"] is used, defaulting to 'upper'.
>
> Note that the vertical axes points upward for 'lower' but downward for 'upper'.
>
>
> On Thu, Jun 6, 2019 at 9:25 AM Neal Becker <[hidden email]> wrote:
>>
>> I just wasted quite a bit of time trying to debug my code.  It took a long
>> time because I was using imshow to debug, and didn't know that imshow
>> displays a matrix not using cartesian coordinates.  The axes are transposed
>> and one axis is reversed.  The documentation doesn't mention this.
>>
>> Thanks,
>> Neal
>>
>> _______________________________________________
>> Matplotlib-users mailing list
>> [hidden email]
>> https://mail.python.org/mailman/listinfo/matplotlib-users



--
Those who don't understand recursion are doomed to repeat it
_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users
Reply | Threaded
Open this post in threaded view
|

Re: please document imshow axes order

tcaswell
In reply to this post by Nathan Goldbaum
There is also a tutorial addressing the ways that `origin` and `extent` interact with each other: https://matplotlib.org/tutorials/intermediate/imshow_extent.html

As for the transpose, that is due to one branch of math teaching use to think (x, y) and different branch of math teaching us to think (row, column).  For `imshow` we use the second one which is consistent with how numpy's repr of on array.  It would be confusing if the data for `my_array[0, :]` was displayed as the first _column_ of the image.

I do not disagree that this is frustrating/confusing, there is a comment in some of my grad school code which is basically "getting the (x,y) vs (r,c) conversions right here took you an afternoon, don't touch this again!" ;)

Tom

On Thu, Jun 6, 2019 at 9:31 AM Nathan Goldbaum <[hidden email]> wrote:
This is discussed in the description of the "origin" keyword argument:

origin : {'upper', 'lower'}, optional

Place the [0,0] index of the array in the upper left or lower left corner of the axes. The convention 'upper' is typically used for matrices and images. If not given, rcParams["image.origin"] is used, defaulting to 'upper'.

Note that the vertical axes points upward for 'lower' but downward for 'upper'.


On Thu, Jun 6, 2019 at 9:25 AM Neal Becker <[hidden email]> wrote:
I just wasted quite a bit of time trying to debug my code.  It took a long
time because I was using imshow to debug, and didn't know that imshow
displays a matrix not using cartesian coordinates.  The axes are transposed
and one axis is reversed.  The documentation doesn't mention this.

Thanks,
Neal

_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users
_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users


--
Thomas Caswell
[hidden email]

_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users
Reply | Threaded
Open this post in threaded view
|

Re: please document imshow axes order

Neal Becker
My suggestion is to enhance the documentation.  If there is a nice
tutorial, adding a link to it would be great.
Thanks,
Neal

On Thu, Jun 6, 2019 at 9:39 AM Thomas Caswell <[hidden email]> wrote:

>
> There is also a tutorial addressing the ways that `origin` and `extent` interact with each other: https://matplotlib.org/tutorials/intermediate/imshow_extent.html
>
> As for the transpose, that is due to one branch of math teaching use to think (x, y) and different branch of math teaching us to think (row, column).  For `imshow` we use the second one which is consistent with how numpy's repr of on array.  It would be confusing if the data for `my_array[0, :]` was displayed as the first _column_ of the image.
>
> I do not disagree that this is frustrating/confusing, there is a comment in some of my grad school code which is basically "getting the (x,y) vs (r,c) conversions right here took you an afternoon, don't touch this again!" ;)
>
> Tom
>
> On Thu, Jun 6, 2019 at 9:31 AM Nathan Goldbaum <[hidden email]> wrote:
>>
>> This is discussed in the description of the "origin" keyword argument:
>>
>> origin : {'upper', 'lower'}, optional
>>
>> Place the [0,0] index of the array in the upper left or lower left corner of the axes. The convention 'upper' is typically used for matrices and images. If not given, rcParams["image.origin"] is used, defaulting to 'upper'.
>>
>> Note that the vertical axes points upward for 'lower' but downward for 'upper'.
>>
>>
>> On Thu, Jun 6, 2019 at 9:25 AM Neal Becker <[hidden email]> wrote:
>>>
>>> I just wasted quite a bit of time trying to debug my code.  It took a long
>>> time because I was using imshow to debug, and didn't know that imshow
>>> displays a matrix not using cartesian coordinates.  The axes are transposed
>>> and one axis is reversed.  The documentation doesn't mention this.
>>>
>>> Thanks,
>>> Neal
>>>
>>> _______________________________________________
>>> Matplotlib-users mailing list
>>> [hidden email]
>>> https://mail.python.org/mailman/listinfo/matplotlib-users
>>
>> _______________________________________________
>> Matplotlib-users mailing list
>> [hidden email]
>> https://mail.python.org/mailman/listinfo/matplotlib-users
>
>
>
> --
> Thomas Caswell
> [hidden email]



--
Those who don't understand recursion are doomed to repeat it
_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users
Reply | Threaded
Open this post in threaded view
|

Re: please document imshow axes order

Saito Kotaro (PSI)
I went through the exact same issue some years ago and wrote a note about this confusing definition of the directions in 2D arrays.
It’s written in Japanese but I think it's still understandable for most of you who can read matplotlib and numpy codes.
https://qiita.com/skotaro/items/1bc4db69b53210d839ec

I hope this would help for improving a tutorial or the documentation.

Best regards,

Kotaro

//================//================//
Paul Scherrer Institut
Kotaro SAITO 斉藤耕太郎
Laboratory for Neutron Scattering and Imaging
WHGA/348
5232 Villigen PSI, Schweiz
+41 56 310 3179
[hidden email]
https://sites.google.com/view/kotarosaito/
//================//================//

> On 2019/6/ 6, at 15:42, Neal Becker <[hidden email]> wrote:
>
> My suggestion is to enhance the documentation.  If there is a nice
> tutorial, adding a link to it would be great.
> Thanks,
> Neal
>
> On Thu, Jun 6, 2019 at 9:39 AM Thomas Caswell <[hidden email]> wrote:
>>
>> There is also a tutorial addressing the ways that `origin` and `extent` interact with each other: https://matplotlib.org/tutorials/intermediate/imshow_extent.html
>>
>> As for the transpose, that is due to one branch of math teaching use to think (x, y) and different branch of math teaching us to think (row, column).  For `imshow` we use the second one which is consistent with how numpy's repr of on array.  It would be confusing if the data for `my_array[0, :]` was displayed as the first _column_ of the image.
>>
>> I do not disagree that this is frustrating/confusing, there is a comment in some of my grad school code which is basically "getting the (x,y) vs (r,c) conversions right here took you an afternoon, don't touch this again!" ;)
>>
>> Tom
>>
>> On Thu, Jun 6, 2019 at 9:31 AM Nathan Goldbaum <[hidden email]> wrote:
>>>
>>> This is discussed in the description of the "origin" keyword argument:
>>>
>>> origin : {'upper', 'lower'}, optional
>>>
>>> Place the [0,0] index of the array in the upper left or lower left corner of the axes. The convention 'upper' is typically used for matrices and images. If not given, rcParams["image.origin"] is used, defaulting to 'upper'.
>>>
>>> Note that the vertical axes points upward for 'lower' but downward for 'upper'.
>>>
>>>
>>> On Thu, Jun 6, 2019 at 9:25 AM Neal Becker <[hidden email]> wrote:
>>>>
>>>> I just wasted quite a bit of time trying to debug my code.  It took a long
>>>> time because I was using imshow to debug, and didn't know that imshow
>>>> displays a matrix not using cartesian coordinates.  The axes are transposed
>>>> and one axis is reversed.  The documentation doesn't mention this.
>>>>
>>>> Thanks,
>>>> Neal
>>>>
>>>> _______________________________________________
>>>> Matplotlib-users mailing list
>>>> [hidden email]
>>>> https://mail.python.org/mailman/listinfo/matplotlib-users
>>>
>>> _______________________________________________
>>> Matplotlib-users mailing list
>>> [hidden email]
>>> https://mail.python.org/mailman/listinfo/matplotlib-users
>>
>>
>>
>> --
>> Thomas Caswell
>> [hidden email]
>
>
>
> --
> Those who don't understand recursion are doomed to repeat it
> _______________________________________________
> Matplotlib-users mailing list
> [hidden email]
> https://mail.python.org/mailman/listinfo/matplotlib-users

_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users
Reply | Threaded
Open this post in threaded view
|

Re: please document imshow axes order

Nathan Goldbaum
In reply to this post by Neal Becker

btw, you can do stuff like this yourself :)

On Thu, Jun 6, 2019 at 9:43 AM Neal Becker <[hidden email]> wrote:
My suggestion is to enhance the documentation.  If there is a nice
tutorial, adding a link to it would be great.
Thanks,
Neal

On Thu, Jun 6, 2019 at 9:39 AM Thomas Caswell <[hidden email]> wrote:
>
> There is also a tutorial addressing the ways that `origin` and `extent` interact with each other: https://matplotlib.org/tutorials/intermediate/imshow_extent.html
>
> As for the transpose, that is due to one branch of math teaching use to think (x, y) and different branch of math teaching us to think (row, column).  For `imshow` we use the second one which is consistent with how numpy's repr of on array.  It would be confusing if the data for `my_array[0, :]` was displayed as the first _column_ of the image.
>
> I do not disagree that this is frustrating/confusing, there is a comment in some of my grad school code which is basically "getting the (x,y) vs (r,c) conversions right here took you an afternoon, don't touch this again!" ;)
>
> Tom
>
> On Thu, Jun 6, 2019 at 9:31 AM Nathan Goldbaum <[hidden email]> wrote:
>>
>> This is discussed in the description of the "origin" keyword argument:
>>
>> origin : {'upper', 'lower'}, optional
>>
>> Place the [0,0] index of the array in the upper left or lower left corner of the axes. The convention 'upper' is typically used for matrices and images. If not given, rcParams["image.origin"] is used, defaulting to 'upper'.
>>
>> Note that the vertical axes points upward for 'lower' but downward for 'upper'.
>>
>>
>> On Thu, Jun 6, 2019 at 9:25 AM Neal Becker <[hidden email]> wrote:
>>>
>>> I just wasted quite a bit of time trying to debug my code.  It took a long
>>> time because I was using imshow to debug, and didn't know that imshow
>>> displays a matrix not using cartesian coordinates.  The axes are transposed
>>> and one axis is reversed.  The documentation doesn't mention this.
>>>
>>> Thanks,
>>> Neal
>>>
>>> _______________________________________________
>>> Matplotlib-users mailing list
>>> [hidden email]
>>> https://mail.python.org/mailman/listinfo/matplotlib-users
>>
>> _______________________________________________
>> Matplotlib-users mailing list
>> [hidden email]
>> https://mail.python.org/mailman/listinfo/matplotlib-users
>
>
>
> --
> Thomas Caswell
> [hidden email]



--
Those who don't understand recursion are doomed to repeat it

_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users
Reply | Threaded
Open this post in threaded view
|

Re: please document imshow axes order

Neal Becker
In reply to this post by Saito Kotaro (PSI)
Actually I found this pdf
https://www.mubdirahman.com/assets/lecture-6---advanced-plotting.pdf
starting at page 6 explained things quite well

On Thu, Jun 6, 2019 at 10:02 AM Saito Kotaro (PSI) <[hidden email]> wrote:

>
> I went through the exact same issue some years ago and wrote a note about this confusing definition of the directions in 2D arrays.
> It’s written in Japanese but I think it's still understandable for most of you who can read matplotlib and numpy codes.
> https://qiita.com/skotaro/items/1bc4db69b53210d839ec
>
> I hope this would help for improving a tutorial or the documentation.
>
> Best regards,
>
> Kotaro
>
> //================//================//
> Paul Scherrer Institut
> Kotaro SAITO 斉藤耕太郎
> Laboratory for Neutron Scattering and Imaging
> WHGA/348
> 5232 Villigen PSI, Schweiz
> +41 56 310 3179
> [hidden email]
> https://sites.google.com/view/kotarosaito/
> //================//================//
>
> > On 2019/6/ 6, at 15:42, Neal Becker <[hidden email]> wrote:
> >
> > My suggestion is to enhance the documentation.  If there is a nice
> > tutorial, adding a link to it would be great.
> > Thanks,
> > Neal
> >
> > On Thu, Jun 6, 2019 at 9:39 AM Thomas Caswell <[hidden email]> wrote:
> >>
> >> There is also a tutorial addressing the ways that `origin` and `extent` interact with each other: https://matplotlib.org/tutorials/intermediate/imshow_extent.html
> >>
> >> As for the transpose, that is due to one branch of math teaching use to think (x, y) and different branch of math teaching us to think (row, column).  For `imshow` we use the second one which is consistent with how numpy's repr of on array.  It would be confusing if the data for `my_array[0, :]` was displayed as the first _column_ of the image.
> >>
> >> I do not disagree that this is frustrating/confusing, there is a comment in some of my grad school code which is basically "getting the (x,y) vs (r,c) conversions right here took you an afternoon, don't touch this again!" ;)
> >>
> >> Tom
> >>
> >> On Thu, Jun 6, 2019 at 9:31 AM Nathan Goldbaum <[hidden email]> wrote:
> >>>
> >>> This is discussed in the description of the "origin" keyword argument:
> >>>
> >>> origin : {'upper', 'lower'}, optional
> >>>
> >>> Place the [0,0] index of the array in the upper left or lower left corner of the axes. The convention 'upper' is typically used for matrices and images. If not given, rcParams["image.origin"] is used, defaulting to 'upper'.
> >>>
> >>> Note that the vertical axes points upward for 'lower' but downward for 'upper'.
> >>>
> >>>
> >>> On Thu, Jun 6, 2019 at 9:25 AM Neal Becker <[hidden email]> wrote:
> >>>>
> >>>> I just wasted quite a bit of time trying to debug my code.  It took a long
> >>>> time because I was using imshow to debug, and didn't know that imshow
> >>>> displays a matrix not using cartesian coordinates.  The axes are transposed
> >>>> and one axis is reversed.  The documentation doesn't mention this.
> >>>>
> >>>> Thanks,
> >>>> Neal
> >>>>
> >>>> _______________________________________________
> >>>> Matplotlib-users mailing list
> >>>> [hidden email]
> >>>> https://mail.python.org/mailman/listinfo/matplotlib-users
> >>>
> >>> _______________________________________________
> >>> Matplotlib-users mailing list
> >>> [hidden email]
> >>> https://mail.python.org/mailman/listinfo/matplotlib-users
> >>
> >>
> >>
> >> --
> >> Thomas Caswell
> >> [hidden email]
> >
> >
> >
> > --
> > Those who don't understand recursion are doomed to repeat it
> > _______________________________________________
> > Matplotlib-users mailing list
> > [hidden email]
> > https://mail.python.org/mailman/listinfo/matplotlib-users
>


--
Those who don't understand recursion are doomed to repeat it
_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users
Reply | Threaded
Open this post in threaded view
|

Re: please document imshow axes order

Jody Klymak
I think a useful way to think about it is to ask how you’d present an x-y array of numbers if you wrote them in a table.  If you saw a table:

1 3 4 7
2 7 8 1
5 9 6 5

and you said this was an array in x and y, I think most people would naturally assume x increases column-wise (i.e. the x-axis of the table) and y increases row-wise (i.e. the y-axis of the table).  Of course the opposite is another sometimes used convention, so its not like there is any fast rule, but I find that a useful justification for the convention numpy/matplotlib use.

C uses the column-major order, but FORTRAN, (and hence Matlab, Numpy, and most other scientific software packages) use row-major:


ie in numpy:

```
In [4]: a = np.array([[1, 2, 3],[4, 5, 6]])

In [6]: print(a)
[[1 2 3]
 [4 5 6]]
```

Cheers,   Jody



On 6 Jun 2019, at 07:11, Neal Becker <[hidden email]> wrote:

Actually I found this pdf
https://www.mubdirahman.com/assets/lecture-6---advanced-plotting.pdf
starting at page 6 explained things quite well

On Thu, Jun 6, 2019 at 10:02 AM Saito Kotaro (PSI) <[hidden email]> wrote:

I went through the exact same issue some years ago and wrote a note about this confusing definition of the directions in 2D arrays.
It’s written in Japanese but I think it's still understandable for most of you who can read matplotlib and numpy codes.
https://qiita.com/skotaro/items/1bc4db69b53210d839ec

I hope this would help for improving a tutorial or the documentation.

Best regards,

Kotaro

//================//================//
Paul Scherrer Institut
Kotaro SAITO 斉藤耕太郎
Laboratory for Neutron Scattering and Imaging
WHGA/348
5232 Villigen PSI, Schweiz
+41 56 310 3179
[hidden email]
https://sites.google.com/view/kotarosaito/
//================//================//

On 2019/6/ 6, at 15:42, Neal Becker <[hidden email]> wrote:

My suggestion is to enhance the documentation.  If there is a nice
tutorial, adding a link to it would be great.
Thanks,
Neal

On Thu, Jun 6, 2019 at 9:39 AM Thomas Caswell <[hidden email]> wrote:

There is also a tutorial addressing the ways that `origin` and `extent` interact with each other: https://matplotlib.org/tutorials/intermediate/imshow_extent.html

As for the transpose, that is due to one branch of math teaching use to think (x, y) and different branch of math teaching us to think (row, column).  For `imshow` we use the second one which is consistent with how numpy's repr of on array.  It would be confusing if the data for `my_array[0, :]` was displayed as the first _column_ of the image.

I do not disagree that this is frustrating/confusing, there is a comment in some of my grad school code which is basically "getting the (x,y) vs (r,c) conversions right here took you an afternoon, don't touch this again!" ;)

Tom

On Thu, Jun 6, 2019 at 9:31 AM Nathan Goldbaum <[hidden email]> wrote:

This is discussed in the description of the "origin" keyword argument:

origin : {'upper', 'lower'}, optional

Place the [0,0] index of the array in the upper left or lower left corner of the axes. The convention 'upper' is typically used for matrices and images. If not given, rcParams["image.origin"] is used, defaulting to 'upper'.

Note that the vertical axes points upward for 'lower' but downward for 'upper'.


On Thu, Jun 6, 2019 at 9:25 AM Neal Becker <[hidden email]> wrote:

I just wasted quite a bit of time trying to debug my code.  It took a long
time because I was using imshow to debug, and didn't know that imshow
displays a matrix not using cartesian coordinates.  The axes are transposed
and one axis is reversed.  The documentation doesn't mention this.

Thanks,
Neal

_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users

_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users



--
Thomas Caswell
[hidden email]



--
Those who don't understand recursion are doomed to repeat it
_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users



-- 
Those who don't understand recursion are doomed to repeat it
_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users

--
Jody Klymak    






_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users
Reply | Threaded
Open this post in threaded view
|

Re: please document imshow axes order

tcaswell
MATLAB and FORTRAN are column-major, C/c++ and numpy are row-major.

Tom

On Thu, Jun 6, 2019 at 12:49 PM Jody Klymak <[hidden email]> wrote:
I think a useful way to think about it is to ask how you’d present an x-y array of numbers if you wrote them in a table.  If you saw a table:

1 3 4 7
2 7 8 1
5 9 6 5

and you said this was an array in x and y, I think most people would naturally assume x increases column-wise (i.e. the x-axis of the table) and y increases row-wise (i.e. the y-axis of the table).  Of course the opposite is another sometimes used convention, so its not like there is any fast rule, but I find that a useful justification for the convention numpy/matplotlib use.

C uses the column-major order, but FORTRAN, (and hence Matlab, Numpy, and most other scientific software packages) use row-major:


ie in numpy:

```
In [4]: a = np.array([[1, 2, 3],[4, 5, 6]])

In [6]: print(a)
[[1 2 3]
 [4 5 6]]
```

Cheers,   Jody



On 6 Jun 2019, at 07:11, Neal Becker <[hidden email]> wrote:

Actually I found this pdf
https://www.mubdirahman.com/assets/lecture-6---advanced-plotting.pdf
starting at page 6 explained things quite well

On Thu, Jun 6, 2019 at 10:02 AM Saito Kotaro (PSI) <[hidden email]> wrote:

I went through the exact same issue some years ago and wrote a note about this confusing definition of the directions in 2D arrays.
It’s written in Japanese but I think it's still understandable for most of you who can read matplotlib and numpy codes.
https://qiita.com/skotaro/items/1bc4db69b53210d839ec

I hope this would help for improving a tutorial or the documentation.

Best regards,

Kotaro

//================//================//
Paul Scherrer Institut
Kotaro SAITO 斉藤耕太郎
Laboratory for Neutron Scattering and Imaging
WHGA/348
5232 Villigen PSI, Schweiz
+41 56 310 3179
[hidden email]
https://sites.google.com/view/kotarosaito/
//================//================//

On 2019/6/ 6, at 15:42, Neal Becker <[hidden email]> wrote:

My suggestion is to enhance the documentation.  If there is a nice
tutorial, adding a link to it would be great.
Thanks,
Neal

On Thu, Jun 6, 2019 at 9:39 AM Thomas Caswell <[hidden email]> wrote:

There is also a tutorial addressing the ways that `origin` and `extent` interact with each other: https://matplotlib.org/tutorials/intermediate/imshow_extent.html

As for the transpose, that is due to one branch of math teaching use to think (x, y) and different branch of math teaching us to think (row, column).  For `imshow` we use the second one which is consistent with how numpy's repr of on array.  It would be confusing if the data for `my_array[0, :]` was displayed as the first _column_ of the image.

I do not disagree that this is frustrating/confusing, there is a comment in some of my grad school code which is basically "getting the (x,y) vs (r,c) conversions right here took you an afternoon, don't touch this again!" ;)

Tom

On Thu, Jun 6, 2019 at 9:31 AM Nathan Goldbaum <[hidden email]> wrote:

This is discussed in the description of the "origin" keyword argument:

origin : {'upper', 'lower'}, optional

Place the [0,0] index of the array in the upper left or lower left corner of the axes. The convention 'upper' is typically used for matrices and images. If not given, rcParams["image.origin"] is used, defaulting to 'upper'.

Note that the vertical axes points upward for 'lower' but downward for 'upper'.


On Thu, Jun 6, 2019 at 9:25 AM Neal Becker <[hidden email]> wrote:

I just wasted quite a bit of time trying to debug my code.  It took a long
time because I was using imshow to debug, and didn't know that imshow
displays a matrix not using cartesian coordinates.  The axes are transposed
and one axis is reversed.  The documentation doesn't mention this.

Thanks,
Neal

_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users

_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users



--
Thomas Caswell
[hidden email]



--
Those who don't understand recursion are doomed to repeat it
_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users



-- 
Those who don't understand recursion are doomed to repeat it
_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users

--
Jody Klymak    





_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users


--
Thomas Caswell
[hidden email]

_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users
Reply | Threaded
Open this post in threaded view
|

Re: please document imshow axes order

Eric Firing
On 2019/06/06 7:12 AM, Thomas Caswell wrote:
> MATLAB and FORTRAN are column-major, C/c++ and numpy are row-major.

Unfortunately, that "-major" terminology is hopelessly confusing--as we
have just seen.
_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/matplotlib-users