Ask Your Question
0

How to plot a list of circles

asked 5 years ago

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 ?

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
1

answered 5 years ago

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
Preview: (hide)
link

Comments

Thanks a lot.

Cyrille gravatar imageCyrille ( 5 years ago )
1

The oneliner

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

should also work

Sébastien gravatar imageSébastien ( 5 years ago )

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: 5 years ago

Seen: 764 times

Last updated: Nov 26 '19