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, 26 Nov 2019 17:11:20 +0100How to plot a list of circleshttps://ask.sagemath.org/question/48887/how-to-plot-a-list-of-circles/ I would like to know if there is a mechanism in SageMath to do the following.
lis=[(4,1),(5,6),(2,2),(3,4),(6,3.2),(2.6,2.5),(5.8, 2.4),(2,3.4),(4.2,4),(5.6,1)]
from sage.plot.circle import Circle
for i in len(lis-1):
p[i]=circle(lis[i], .05, fill=true, color='red')
(unfortunately my code is wrong) and then to do a sum of the `p[i]` to plot the circles ?Tue, 26 Nov 2019 10:09:46 +0100https://ask.sagemath.org/question/48887/how-to-plot-a-list-of-circles/Answer by tmonteil for <p>I would like to know if there is a mechanism in SageMath to do the following.</p>
<pre><code>lis=[(4,1),(5,6),(2,2),(3,4),(6,3.2),(2.6,2.5),(5.8, 2.4),(2,3.4),(4.2,4),(5.6,1)]
from sage.plot.circle import Circle
for i in len(lis-1):
p[i]=circle(lis[i], .05, fill=true, color='red')
</code></pre>
<p>(unfortunately my code is wrong) and then to do a sum of the <code>p[i]</code> to plot the circles ?</p>
https://ask.sagemath.org/question/48887/how-to-plot-a-list-of-circles/?answer=48888#post-id-48888You can start from an empty graphics, and add circles to it directly as follows:
sage: G = Graphics()
sage: for c in lis:
....: G += circle(c, .05, fill=true, color='red')
Then, you can show it with:
sage: G
Tue, 26 Nov 2019 11:28:01 +0100https://ask.sagemath.org/question/48887/how-to-plot-a-list-of-circles/?answer=48888#post-id-48888Comment by Cyrille for <p>You can start from an empty graphics, and add circles to it directly as follows:</p>
<pre><code>sage: G = Graphics()
sage: for c in lis:
....: G += circle(c, .05, fill=true, color='red')
</code></pre>
<p>Then, you can show it with:</p>
<pre><code>sage: G
</code></pre>
https://ask.sagemath.org/question/48887/how-to-plot-a-list-of-circles/?comment=48889#post-id-48889Thanks a lot.Tue, 26 Nov 2019 11:39:15 +0100https://ask.sagemath.org/question/48887/how-to-plot-a-list-of-circles/?comment=48889#post-id-48889Comment by Sébastien for <p>You can start from an empty graphics, and add circles to it directly as follows:</p>
<pre><code>sage: G = Graphics()
sage: for c in lis:
....: G += circle(c, .05, fill=true, color='red')
</code></pre>
<p>Then, you can show it with:</p>
<pre><code>sage: G
</code></pre>
https://ask.sagemath.org/question/48887/how-to-plot-a-list-of-circles/?comment=48896#post-id-48896The oneliner
sum(circle(c, .05, fill=True, color='red') for c in lis)
should also workTue, 26 Nov 2019 17:11:20 +0100https://ask.sagemath.org/question/48887/how-to-plot-a-list-of-circles/?comment=48896#post-id-48896