ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Thu, 19 Apr 2018 00:22:11 -0500How does list_plot3d interpret nxn matrices?http://ask.sagemath.org/question/42091/how-does-list_plot3d-interpret-nxn-matrices/ From the [documentation](http://doc.sagemath.org/html/en/reference/plot3d/sage/plot/plot3d/list_plot3d.html) of `list_plot3d`
>INPUT:
>v - something that defines a set of points in 3 space, for example:
> - a matrix
> - a list of 3-tuples
> - a list of lists (all of the same length) - this is treated the same as a matrix.
Intuitively I would guess that the function would only accept $3 \times n$ matrices and/or their transposes, but the first example on the document page is a plot of a five by five matrix
n = 5
m = matrix(RDF, n, [(i+j)%n for i in [1..n] for j in [1..n]])
p = list_plot3d(m)
p
**Question**: How does `list_plot3d` interpret this $5 \times 5$ matrix as a set of points in 3-space?
One might suspect that `list_plot3d` handles matrices the same was as, for example, `point3d` but this is not the case. For example, the points visualized by `point3d` do not lie on the surface given by `list_plot3d` in the above example as witnessed by
p + point3d(m, size=33)
Wed, 18 Apr 2018 13:34:16 -0500http://ask.sagemath.org/question/42091/how-does-list_plot3d-interpret-nxn-matrices/Answer by John Palmieri for <p>From the <a href="http://doc.sagemath.org/html/en/reference/plot3d/sage/plot/plot3d/list_plot3d.html">documentation</a> of <code>list_plot3d</code></p>
<blockquote>
<p>INPUT:</p>
<p>v - something that defines a set of points in 3 space, for example:</p>
<ul>
<li>a matrix</li>
<li>a list of 3-tuples</li>
<li>a list of lists (all of the same length) - this is treated the same as a matrix.</li>
</ul>
</blockquote>
<p>Intuitively I would guess that the function would only accept $3 \times n$ matrices and/or their transposes, but the first example on the document page is a plot of a five by five matrix</p>
<pre><code>n = 5
m = matrix(RDF, n, [(i+j)%n for i in [1..n] for j in [1..n]])
p = list_plot3d(m)
p
</code></pre>
<p><strong>Question</strong>: How does <code>list_plot3d</code> interpret this $5 \times 5$ matrix as a set of points in 3-space?</p>
<p>One might suspect that <code>list_plot3d</code> handles matrices the same was as, for example, <code>point3d</code> but this is not the case. For example, the points visualized by <code>point3d</code> do not lie on the surface given by <code>list_plot3d</code> in the above example as witnessed by</p>
<pre><code>p + point3d(m, size=33)
</code></pre>
http://ask.sagemath.org/question/42091/how-does-list_plot3d-interpret-nxn-matrices/?answer=42092#post-id-42092I agree that it is completely unclear from the documentation. I believe that if `m` is a matrix, then this plots the points `(i,j,m_{i,j})`; that is, above the point `(i,j)` in the `(x,y)`-plane, it plots the `z`-value `m_{i,j}`.Wed, 18 Apr 2018 23:38:09 -0500http://ask.sagemath.org/question/42091/how-does-list_plot3d-interpret-nxn-matrices/?answer=42092#post-id-42092Comment by amdall for <p>I agree that it is completely unclear from the documentation. I believe that if <code>m</code> is a matrix, then this plots the points <code>(i,j,m_{i,j})</code>; that is, above the point <code>(i,j)</code> in the <code>(x,y)</code>-plane, it plots the <code>z</code>-value <code>m_{i,j}</code>.</p>
http://ask.sagemath.org/question/42091/how-does-list_plot3d-interpret-nxn-matrices/?comment=42094#post-id-42094As a side note, the behavior of `list_plot3d` and `point3d` on matrices do not seem related.Thu, 19 Apr 2018 00:22:11 -0500http://ask.sagemath.org/question/42091/how-does-list_plot3d-interpret-nxn-matrices/?comment=42094#post-id-42094Comment by amdall for <p>I agree that it is completely unclear from the documentation. I believe that if <code>m</code> is a matrix, then this plots the points <code>(i,j,m_{i,j})</code>; that is, above the point <code>(i,j)</code> in the <code>(x,y)</code>-plane, it plots the <code>z</code>-value <code>m_{i,j}</code>.</p>
http://ask.sagemath.org/question/42091/how-does-list_plot3d-interpret-nxn-matrices/?comment=42093#post-id-42093That makes sense. And it also serves as a natural 3D extension to the output obtained from calling `plot` or `matrix_plot` an an $n \times n$ matrix.Thu, 19 Apr 2018 00:22:00 -0500http://ask.sagemath.org/question/42091/how-does-list_plot3d-interpret-nxn-matrices/?comment=42093#post-id-42093