Ask Your Question
0

How to plot a list of circles

asked 2019-11-26 03:09:46 -0600

Cyrille gravatar image

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 ?

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted
1

answered 2019-11-26 04:28:01 -0600

tmonteil gravatar image

You 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
edit flag offensive delete link more

Comments

Thanks a lot.

Cyrille gravatar imageCyrille ( 2019-11-26 04:39:15 -0600 )edit
1

The oneliner

sum(circle(c, .05, fill=True, color='red') for c in lis)

should also work

Sébastien gravatar imageSébastien ( 2019-11-26 10:11:20 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2019-11-26 03:09:46 -0600

Seen: 29 times

Last updated: Nov 26