# How to think about indices and cartesian coordinates?

**URL:** <https://discourse.julialang.org/t/how-to-think-about-indices-and-cartesian-coordinates/95972>\
**Category:** New to Julia\
**Tags:** question, plotting, plots, matrix\
**Created:** [March 12, 2023, 7:12pm UTC](https://discourse.julialang.org/t/how-to-think-about-indices-and-cartesian-coordinates/95972 "2023-03-12T19:12:20Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![DNF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dnf/32/10191_2.png) [@DNF](https://discourse.julialang.org/u/DNF)\
**Post date:** [March 12, 2023, 11:07pm UTC](https://discourse.julialang.org/t/how-to-think-about-indices-and-cartesian-coordinates/95972/3 "2023-03-12T23:07:07Z")

</div>

> [@isaque](#):
>
> Is it correct to think of the first index (`i`) as the y direction, and the second index (`j`) as the x direction?

It is really neither correct nor incorrect, it is really up to you to choose a convention for yourself. Unfortunately.

The problem is that we are used to thinking of x as the first dimension and y as the second dimension, while in linear algebra the first dimension is ‘downwards’ and the second dimension is ‘across’.

Every time, I struggle with choosing a convention, and I personally believe everything would be much nicer if the first index always was the x-direction, and also indicated column (the opposite of today).

So, it’s up to you.

> [@isaque](#):
>
> ```julia
> X = ones(Float64, n) * collect(1:n)'
> Y = collect(1:n) * ones(Float64, n)'
> 
> ```

I urge you to not get into the habit of using `collect`. It is wasteful and pointless here. Forget you ever heard of that function. Remove it from all your codes, and don’t use until your code stops working without it.

---

_[View the full topic](https://discourse.julialang.org/t/how-to-think-about-indices-and-cartesian-coordinates/95972)._
