<div dir="ltr"><div>MATLAB and FORTRAN are column-major, C/c++ and numpy are row-major.<br></div><div><div><br></div><div>Tom</div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Jun 6, 2019 at 12:49 PM Jody Klymak <<a href="mailto:jklymak@uvic.ca">jklymak@uvic.ca</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="overflow-wrap: break-word;">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:<div><br></div><div>1 3 4 7</div><div>2 7 8 1</div><div>5 9 6 5</div><div><br></div><div>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.</div><div><br></div><div>C uses the column-major order, but FORTRAN, (and hence Matlab, Numpy, and most other scientific software packages) use row-major:</div><div><br></div><div><a href="https://en.wikipedia.org/wiki/Row-_and_column-major_order" target="_blank">https://en.wikipedia.org/wiki/Row-_and_column-major_order</a></div><div><br></div><div>ie in numpy:</div><div><br></div><div>```</div><div><div>In [4]: a = np.array([[1, 2, 3],[4, 5, 6]])</div><div><br></div><div><div>In [6]: print(a)</div><div>[[1 2 3]</div><div> [4 5 6]]</div></div></div><div>```</div><div><br></div><div>Cheers,   Jody</div><div><br></div><div><br></div><div><br></div><div><div><blockquote type="cite"><div>On 6 Jun 2019, at 07:11, Neal Becker <<a href="mailto:ndbecker2@gmail.com" target="_blank">ndbecker2@gmail.com</a>> wrote:</div><br class="gmail-m_-4202082947818207402Apple-interchange-newline"><div><span style="font-family:BitstreamVeraSansMono-Roman;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline">Actually I found this pdf</span><br style="font-family:BitstreamVeraSansMono-Roman;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><a href="https://www.mubdirahman.com/assets/lecture-6---advanced-plotting.pdf" style="font-family:BitstreamVeraSansMono-Roman;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank">https://www.mubdirahman.com/assets/lecture-6---advanced-plotting.pdf</a><br style="font-family:BitstreamVeraSansMono-Roman;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><span style="font-family:BitstreamVeraSansMono-Roman;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline">starting at page 6 explained things quite well</span><br style="font-family:BitstreamVeraSansMono-Roman;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><br style="font-family:BitstreamVeraSansMono-Roman;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><span style="font-family:BitstreamVeraSansMono-Roman;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline">On Thu, Jun 6, 2019 at 10:02 AM Saito Kotaro (PSI) <</span><a href="mailto:kotaro.saito@psi.ch" style="font-family:BitstreamVeraSansMono-Roman;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank">kotaro.saito@psi.ch</a><span style="font-family:BitstreamVeraSansMono-Roman;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline">> wrote:</span><br style="font-family:BitstreamVeraSansMono-Roman;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><blockquote type="cite" style="font-family:BitstreamVeraSansMono-Roman;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><br>I went through the exact same issue some years ago and wrote a note about this confusing definition of the directions in 2D arrays.<br>It’s written in Japanese but I think it's still understandable for most of you who can read matplotlib and numpy codes.<br><a href="https://qiita.com/skotaro/items/1bc4db69b53210d839ec" target="_blank">https://qiita.com/skotaro/items/1bc4db69b53210d839ec</a><br><br>I hope this would help for improving a tutorial or the documentation.<br><br>Best regards,<br><br>Kotaro<br><br>//================//================//<br>Paul Scherrer Institut<br>Kotaro SAITO 斉藤耕太郎<br>Laboratory for Neutron Scattering and Imaging<br>WHGA/348<br>5232 Villigen PSI, Schweiz<br>+41 56 310 3179<br><a href="mailto:kotaro.saito@psi.ch" target="_blank">kotaro.saito@psi.ch</a><br><a href="https://sites.google.com/view/kotarosaito/" target="_blank">https://sites.google.com/view/kotarosaito/</a><br>//================//================//<br><br><blockquote type="cite">On 2019/6/ 6, at 15:42, Neal Becker <<a href="mailto:ndbecker2@gmail.com" target="_blank">ndbecker2@gmail.com</a>> wrote:<br><br>My suggestion is to enhance the documentation.  If there is a nice<br>tutorial, adding a link to it would be great.<br>Thanks,<br>Neal<br><br>On Thu, Jun 6, 2019 at 9:39 AM Thomas Caswell <<a href="mailto:tcaswell@gmail.com" target="_blank">tcaswell@gmail.com</a>> wrote:<br><blockquote type="cite"><br>There is also a tutorial addressing the ways that `origin` and `extent` interact with each other: <a href="https://matplotlib.org/tutorials/intermediate/imshow_extent.html" target="_blank">https://matplotlib.org/tutorials/intermediate/imshow_extent.html</a><br><br>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.<br><br>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!" ;)<br><br>Tom<br><br>On Thu, Jun 6, 2019 at 9:31 AM Nathan Goldbaum <<a href="mailto:nathan12343@gmail.com" target="_blank">nathan12343@gmail.com</a>> wrote:<br><blockquote type="cite"><br>This is discussed in the description of the "origin" keyword argument:<br><br>origin : {'upper', 'lower'}, optional<br><br>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'.<br><br>Note that the vertical axes points upward for 'lower' but downward for 'upper'.<br><br><br>On Thu, Jun 6, 2019 at 9:25 AM Neal Becker <<a href="mailto:ndbecker2@gmail.com" target="_blank">ndbecker2@gmail.com</a>> wrote:<br><blockquote type="cite"><br>I just wasted quite a bit of time trying to debug my code.  It took a long<br>time because I was using imshow to debug, and didn't know that imshow<br>displays a matrix not using cartesian coordinates.  The axes are transposed<br>and one axis is reversed.  The documentation doesn't mention this.<br><br>Thanks,<br>Neal<br><br>_______________________________________________<br>Matplotlib-users mailing list<br><a href="mailto:Matplotlib-users@python.org" target="_blank">Matplotlib-users@python.org</a><br><a href="https://mail.python.org/mailman/listinfo/matplotlib-users" target="_blank">https://mail.python.org/mailman/listinfo/matplotlib-users</a><br></blockquote><br>_______________________________________________<br>Matplotlib-users mailing list<br><a href="mailto:Matplotlib-users@python.org" target="_blank">Matplotlib-users@python.org</a><br><a href="https://mail.python.org/mailman/listinfo/matplotlib-users" target="_blank">https://mail.python.org/mailman/listinfo/matplotlib-users</a><br></blockquote><br><br><br>--<br>Thomas Caswell<br><a href="mailto:tcaswell@gmail.com" target="_blank">tcaswell@gmail.com</a><br></blockquote><br><br><br>--<br>Those who don't understand recursion are doomed to repeat it<br>_______________________________________________<br>Matplotlib-users mailing list<br><a href="mailto:Matplotlib-users@python.org" target="_blank">Matplotlib-users@python.org</a><br><a href="https://mail.python.org/mailman/listinfo/matplotlib-users" target="_blank">https://mail.python.org/mailman/listinfo/matplotlib-users</a><br></blockquote><br></blockquote><br style="font-family:BitstreamVeraSansMono-Roman;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><br style="font-family:BitstreamVeraSansMono-Roman;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><span style="font-family:BitstreamVeraSansMono-Roman;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline">--<span class="gmail-m_-4202082947818207402Apple-converted-space"> </span></span><br style="font-family:BitstreamVeraSansMono-Roman;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><span style="font-family:BitstreamVeraSansMono-Roman;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline">Those who don't understand recursion are doomed to repeat it</span><br style="font-family:BitstreamVeraSansMono-Roman;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><span style="font-family:BitstreamVeraSansMono-Roman;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline">_______________________________________________</span><br style="font-family:BitstreamVeraSansMono-Roman;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><span style="font-family:BitstreamVeraSansMono-Roman;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline">Matplotlib-users mailing list</span><br style="font-family:BitstreamVeraSansMono-Roman;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><a href="mailto:Matplotlib-users@python.org" style="font-family:BitstreamVeraSansMono-Roman;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank">Matplotlib-users@python.org</a><br style="font-family:BitstreamVeraSansMono-Roman;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><a href="https://mail.python.org/mailman/listinfo/matplotlib-users" style="font-family:BitstreamVeraSansMono-Roman;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank">https://mail.python.org/mailman/listinfo/matplotlib-users</a></div></blockquote></div><br><div>
<span class="gmail-m_-4202082947818207402Apple-style-span" style="border-collapse:separate;border-spacing:0px;font-variant-ligatures:normal;font-variant-east-asian:normal;line-height:normal"><div style="overflow-wrap: break-word;"><span class="gmail-m_-4202082947818207402Apple-style-span" style="border-collapse:separate;border-spacing:0px;color:rgb(0,0,0);font-family:"Lucida Sans Typewriter";font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div>--</div><div>Jody Klymak    </div><div><a href="http://web.uvic.ca/~jklymak/" target="_blank">http://web.uvic.ca/~jklymak/</a></div><div><br class="gmail-m_-4202082947818207402khtml-block-placeholder"></div><div><br class="gmail-m_-4202082947818207402khtml-block-placeholder"></div><br class="gmail-m_-4202082947818207402Apple-interchange-newline"></span></div></span><br class="gmail-m_-4202082947818207402Apple-interchange-newline">
</div>
<br></div></div>_______________________________________________<br>
Matplotlib-users mailing list<br>
<a href="mailto:Matplotlib-users@python.org" target="_blank">Matplotlib-users@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/matplotlib-users" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/matplotlib-users</a><br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature">Thomas Caswell<br><a href="mailto:tcaswell@gmail.com" target="_blank">tcaswell@gmail.com</a></div>