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.Tue, 09 Dec 2014 13:21:05 -0600How can I plot points given by code?http://ask.sagemath.org/question/25177/how-can-i-plot-points-given-by-code/ I want to plot the points, that I get from the following code all together in one plot. How can I do that?
for x in range(11):
for y in range(ceil(0.5*(x+4)),(2*x-3)):
print (x,y,x+y-2)
ThanksTue, 09 Dec 2014 09:11:30 -0600http://ask.sagemath.org/question/25177/how-can-i-plot-points-given-by-code/Answer by kcrisman for <p>I want to plot the points, that I get from the following code all together in one plot. How can I do that?</p>
<pre><code>for x in range(11):
for y in range(ceil(0.5*(x+4)),(2*x-3)):
print (x,y,x+y-2)
</code></pre>
<p>Thanks</p>
http://ask.sagemath.org/question/25177/how-can-i-plot-points-given-by-code/?answer=25178#post-id-25178You could make a list of all your points and then use the function [point](http://www.sagemath.org/doc/reference/plotting/sage/plot/point.html#sage.plot.point.point) or you could make a `point` for each one and then add them (by syntax like `point((1,2,3))+point((2,3,4))+point((3,4,5))`).Tue, 09 Dec 2014 09:22:09 -0600http://ask.sagemath.org/question/25177/how-can-i-plot-points-given-by-code/?answer=25178#post-id-25178Comment by legeh for <p>You could make a list of all your points and then use the function <a href="http://www.sagemath.org/doc/reference/plotting/sage/plot/point.html#sage.plot.point.point">point</a> or you could make a <code>point</code> for each one and then add them (by syntax like <code>point((1,2,3))+point((2,3,4))+point((3,4,5))</code>).</p>
http://ask.sagemath.org/question/25177/how-can-i-plot-points-given-by-code/?comment=25179#post-id-25179Ideally I would like to use a method that works for an infinite number of points (ie. for bigger ranges too). So adding them one by one is not ideal.
How do I make a list and plot it?
edit: got it
L = [(x,y,x+y-2) for x in range(11) for y in range(ceil(0.5*(x+4)),min((2*x-3),11))]
points(L)
Thanks!Tue, 09 Dec 2014 10:08:33 -0600http://ask.sagemath.org/question/25177/how-can-i-plot-points-given-by-code/?comment=25179#post-id-25179Comment by kcrisman for <p>You could make a list of all your points and then use the function <a href="http://www.sagemath.org/doc/reference/plotting/sage/plot/point.html#sage.plot.point.point">point</a> or you could make a <code>point</code> for each one and then add them (by syntax like <code>point((1,2,3))+point((2,3,4))+point((3,4,5))</code>).</p>
http://ask.sagemath.org/question/25177/how-can-i-plot-points-given-by-code/?comment=25181#post-id-25181Great! When you said 'infinite' I started getting worried, but I think you meant 'arbitrary' - Sage does not yet support plotting infinity :)Tue, 09 Dec 2014 10:53:42 -0600http://ask.sagemath.org/question/25177/how-can-i-plot-points-given-by-code/?comment=25181#post-id-25181Answer by mmarco for <p>I want to plot the points, that I get from the following code all together in one plot. How can I do that?</p>
<pre><code>for x in range(11):
for y in range(ceil(0.5*(x+4)),(2*x-3)):
print (x,y,x+y-2)
</code></pre>
<p>Thanks</p>
http://ask.sagemath.org/question/25177/how-can-i-plot-points-given-by-code/?answer=25182#post-id-25182 I think the function you are looking for is list_plot.
Tue, 09 Dec 2014 13:21:05 -0600http://ask.sagemath.org/question/25177/how-can-i-plot-points-given-by-code/?answer=25182#post-id-25182