Ask Your Question

Revision history [back]

How to save plots to list?

I'd like to create an animation of a 2D plot. This works:

anz=10;
Lambda=2*7/anz*pi;
xm=R*Lambda;
plots = [parametric_plot((x(phi,1),y(phi,1)),(phi,0,2*pi))+circle((x(2*i/anz*pi,1),y(2*i/anz*pi,1)),R/40,color='red')+circle((R*2*i/anz*pi,R),R,color='cyan')+circle((R*2*i/anz*pi,R),R/25,color='magenta')+arc((R*2*i/anz*pi,R), R, sector=(-2*i/anz*pi-pi/2,-pi/2),color='red') for i in range(0,anz)]

anim=animate(plots);
anim;

But I'd like to make it a bit more readable, like this:

anz=10;

for i in range(0,anz):
    Lambda=2*i/anz*pi;
    xm=R*Lambda;
    p[i]=parametric_plot((x(phi,1),y(phi,1)),(phi,0,2*pi));
    p[i]+=circle((x(Lambda,1),y(Lambda,1)),R/40,color='red');
    p[i]+=circle((xm,R),R,color='cyan');
    p[i]+=circle((xm,R),R/25,color='magenta');
    p[i]+=arc((xm,R), R, sector=(-Lambda-pi/2,-pi/2),color='red');

p_anim=animate(p)
p;

How do I create a list of GraphicPrimitives and so that this works?