First time here? Check out the FAQ!

Ask Your Question
0

iterating plots

asked 4 years ago

Cyrille gravatar image

updated 4 years ago

I want to plot several polygon whose coordonates are in a list. I know that we can add plot or use =+. But I wonder if there is a mechanism as sum() which can be iterated. For instance, this gives an error

l=list([1, 2, 3, 5])
ll=list([10, 20, 30, 40])
sum(plot(polygon([(l[j],0),(l[j],ll[j]),(l[j+1],ll[j]),(l[j+1],0)]) for j in range(len(l)-1)))
Preview: (hide)

1 Answer

Sort by » oldest newest most voted
0

answered 4 years ago

FrédéricC gravatar image

Comme ca:

sum(plot(cos(x+i/100),0,1) for i in range(10))
Preview: (hide)
link

Comments

Thanks FrédéricC, but in my case (may be an error) it doesn't work. I have added my code.

Cyrille gravatar imageCyrille ( 4 years ago )

Faut mettre les parentheses au bon endroit.

l=list([1, 2, 3, 5])
ll=list([10, 20, 30, 40])
sum(plot(polygon([(l[j],0),(l[j],ll[j]),(l[j+1],ll[j]),(l[j+1],0)])) for j in range(len(l)-1))
FrédéricC gravatar imageFrédéricC ( 4 years ago )

Thanks I feel stupid.

Cyrille gravatar imageCyrille ( 4 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: 4 years ago

Seen: 184 times

Last updated: Jun 19 '20