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:

Row- and column-major order - Wikipedia

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 <ndbecker2 at gmail.com> 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) <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.

N行N列のnumpy arrayを扱う際に気をつけるべき方向と座標の定義 #Python - Qiita

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

Kotaro Saito - 斉藤耕太郎

//================//================//

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

Matplotlib-users Info Page

_______________________________________________

Matplotlib-users mailing list

Matplotlib-users at python.org

Matplotlib-users Info Page

--

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

Matplotlib-users Info Page

--

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

_______________________________________________

Matplotlib-users mailing list

Matplotlib-users at python.org

Matplotlib-users Info Page

--

Jody Klymak

Jody M. Klymak - UVic Ocean Physics

_______________________________________________

Matplotlib-users mailing list

Matplotlib-users at python.org

Matplotlib-users Info Page