ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 02 Jul 2019 11:56:00 +0200Octave-like plot function, or, how to plot sequence of points?https://ask.sagemath.org/question/47029/octave-like-plot-function-or-how-to-plot-sequence-of-points/Let's say I have the following set of points: (1, 2), (5, 8), (7, 13), (8, 10), (8.7, 9), (10, 6.3), (13, 2), (15, -1).
I would like to plot a 2D graph passing through them.
In octave, I can do the following:
octave:47> x = [1, 5, 7, 8, 8.7, 10, 13, 15]
octave:48> y = [2, 8, 13, 10, 9, 6.3, 2, -1]
octave:49> plot(x, y)
And I get this [graph](https://drive.google.com/open?id=1iE4hhpcYBGwjAvF45F_hruxKwpl3ccvV).
How can I do something similar in sage?
Tue, 02 Jul 2019 09:00:09 +0200https://ask.sagemath.org/question/47029/octave-like-plot-function-or-how-to-plot-sequence-of-points/Answer by Emmanuel Charpentier for <p>Let's say I have the following set of points: (1, 2), (5, 8), (7, 13), (8, 10), (8.7, 9), (10, 6.3), (13, 2), (15, -1).</p>
<p>I would like to plot a 2D graph passing through them. </p>
<p>In octave, I can do the following:</p>
<pre><code>octave:47> x = [1, 5, 7, 8, 8.7, 10, 13, 15]
octave:48> y = [2, 8, 13, 10, 9, 6.3, 2, -1]
octave:49> plot(x, y)
</code></pre>
<p>And I get this <a href="https://drive.google.com/open?id=1iE4hhpcYBGwjAvF45F_hruxKwpl3ccvV">graph</a>.</p>
<p>How can I do something similar in sage?</p>
https://ask.sagemath.org/question/47029/octave-like-plot-function-or-how-to-plot-sequence-of-points/?answer=47033#post-id-47033sage: X = [1, 5, 7, 8, 8.7, 10, 13, 15]
sage: Y = [2, 8, 13, 10, 9, 6.3, 2, -1]
sage: points(zip(X,Y))
Launched png viewer for Graphics object consisting of 1 graphics primitive
![Result](/upfiles/15620613285780435.png)
sage: line(zip(X,Y))
![image description](/upfiles/156206153958094.png)Tue, 02 Jul 2019 11:56:00 +0200https://ask.sagemath.org/question/47029/octave-like-plot-function-or-how-to-plot-sequence-of-points/?answer=47033#post-id-47033Answer by Juanjo for <p>Let's say I have the following set of points: (1, 2), (5, 8), (7, 13), (8, 10), (8.7, 9), (10, 6.3), (13, 2), (15, -1).</p>
<p>I would like to plot a 2D graph passing through them. </p>
<p>In octave, I can do the following:</p>
<pre><code>octave:47> x = [1, 5, 7, 8, 8.7, 10, 13, 15]
octave:48> y = [2, 8, 13, 10, 9, 6.3, 2, -1]
octave:49> plot(x, y)
</code></pre>
<p>And I get this <a href="https://drive.google.com/open?id=1iE4hhpcYBGwjAvF45F_hruxKwpl3ccvV">graph</a>.</p>
<p>How can I do something similar in sage?</p>
https://ask.sagemath.org/question/47029/octave-like-plot-function-or-how-to-plot-sequence-of-points/?answer=47032#post-id-47032You can use the `list_plot` function:
x = [1, 5, 7, 8, 8.7, 10, 13, 15]
y = [2, 8, 13, 10, 9, 6.3, 2, -1]
list_plot(zip(x,y), plotjoined=True)
Se the [docs](http://doc.sagemath.org/html/en/reference/plotting/sage/plot/plot.html#sage.plot.plot.list_plot) for a complete reference.Tue, 02 Jul 2019 11:47:12 +0200https://ask.sagemath.org/question/47029/octave-like-plot-function-or-how-to-plot-sequence-of-points/?answer=47032#post-id-47032