[Matplotlib-users] please document imshow axes order

Neal Becker ndbecker2 at gmail.com
Thu Jun 6 10:11:00 EDT 2019


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) <kotaro.saito at psi.ch> 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
> kotaro.saito at psi.ch
> https://sites.google.com/view/kotarosaito/
> //================//================//
>
> > On 2019/6/ 6, at 15:42, Neal Becker <ndbecker2 at gmail.com> 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 <tcaswell at gmail.com> 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 <nathan12343 at gmail.com> 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 <ndbecker2 at gmail.com> 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
> >>>> Matplotlib-users at python.org
> >>>> https://mail.python.org/mailman/listinfo/matplotlib-users
> >>>
> >>> _______________________________________________
> >>> Matplotlib-users mailing list
> >>> Matplotlib-users at python.org
> >>> https://mail.python.org/mailman/listinfo/matplotlib-users
> >>
> >>
> >>
> >> --
> >> Thomas Caswell
> >> tcaswell at gmail.com
> >
> >
> >
> > --
> > Those who don't understand recursion are doomed to repeat it
> > _______________________________________________
> > Matplotlib-users mailing list
> > Matplotlib-users at python.org
> > https://mail.python.org/mailman/listinfo/matplotlib-users
>


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


More information about the Matplotlib-users mailing list