Ask Your Question
0

iterating plots

asked 2020-06-19 10:06:06 -0500

Cyrille gravatar image

updated 2020-06-19 10:49:16 -0500

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)))
edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted
0

answered 2020-06-19 10:15:39 -0500

FrédéricC gravatar image

Comme ca:

sum(plot(cos(x+i/100),0,1) for i in range(10))
edit flag offensive delete link more

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 ( 2020-06-19 10:48:25 -0500 )edit

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 ( 2020-06-19 11:10:21 -0500 )edit

Thanks I feel stupid.

Cyrille gravatar imageCyrille ( 2020-06-19 15:34:11 -0500 )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: 2020-06-19 10:06:06 -0500

Seen: 60 times

Last updated: Jun 19