Ask Your Question
0

iterating plots

asked 2020-06-19 17:06:06 +0100

Cyrille gravatar image

updated 2020-06-19 17:49:16 +0100

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 17:15:39 +0100

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 17:48:25 +0100 )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 18:10:21 +0100 )edit

Thanks I feel stupid.

Cyrille gravatar imageCyrille ( 2020-06-19 22:34:11 +0100 )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 17:06:06 +0100

Seen: 155 times

Last updated: Jun 19 '20