MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Animate parametric plot of two lists?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg101514] Re: [mg101475] Animate parametric plot of two lists?
  • From: "David Park" <djmpark at comcast.net>
  • Date: Thu, 9 Jul 2009 01:55:36 -0400 (EDT)
  • References: <27402470.1247054225882.JavaMail.root@n11>

I'm not certain which is better, to store a large number of complete plots,
or to generate each one.

Generating each of the plots, which seems to be rapid enough for me, could
be done as follows.

f[t_] := Cos[t] 
g[t_] := Sin[t]

list1 = Table[f[t], {t, 0, 2 Pi, .1}];
list2 = Table[g[t], {t, 0, 2 Pi, .1}];

n = Length[list1];
plotdat = Thread[{list1, list2}];

Animate[
 Show[
  ListPlot[Take[plotdat, k],
   Joined -> True,
   PlotStyle -> {Red, Dashed},
   AspectRatio -> Automatic,
   PlotRange -> 1.2],
  ListPlot[Take[plotdat, k],
   PlotMarkers -> {Automatic, 12},
   AspectRatio -> Automatic,
   PlotRange -> 1.2]
  ],
 {k, 1, n, 1}]

But not (for some reason that I don't understand) as follows:

Animate[
 Show[
  ListPlot[Take[plotdat, k],
   PlotMarkers -> {Automatic, 12},
   AspectRatio -> Automatic,
   PlotRange -> 1.2],
  ListPlot[Take[plotdat, k],
   Joined -> True,
   PlotStyle -> {Red, Dashed},
   AspectRatio -> Automatic,
   PlotRange -> 1.2]
  ],
 {k, 1, n, 1}]

But, as usual, I find it easier to do it with Presentations where the
various uses of the options are untangled and the order doesn't matter.

Needs["Presentations`Master`"]

Animate[
 Draw2D[
  {ListDraw[Take[plotdat, k],
    PlotMarkers -> {Automatic, 12}],
   ListDraw[Take[plotdat, k],
    Joined -> True,
    PlotStyle -> {Red, Dashed}]},
  Axes -> True,
  PlotRange -> 1.2],
 {k, 1, n, 1}]

If you wanted to pre-compute all of the frames, you could just pre-compute
the primitives without generating the entire plots.

Clear[frame]
frame[k_]:={ListDraw[Take[plotdat,k],
PlotMarkers->{Automatic,12}],
ListDraw[Take[plotdat,k],
Joined->True,
PlotStyle->{Red,Dashed}]};
framelist=Table[frame[k],{k,1,n}];

Animate[
 Draw2D[
  {framelist[[k]]},
  PlotRange -> 1.2,
  Axes -> True],
 {k, 1, n, 1}]


David Park
djmpark at comcast.net
http://home.comcast.net/~djmpark/  


From: Porscha Louise McRobbie [mailto:pmcrobbi at umich.edu] 

Hello,

When I have explicit formulas for two functions of time, it's simple 
to animate the parametric plot of them by using ParametricPlot inside 
Animate.

I'd like to create a similar animation now, but using two lists of 
numbers. Apparently there is  no function such as ListParametricPlot.

Below a roundabout way I found (I want to show both a dashed line and 
a point tracing out the curve in time). Is there a better way to do 
this? I'd like to be able to include many more frames, and this method 
seems inefficient.

Any suggestion/help is appreciated.

Porscha



(*Animate a parametric plot from two lists*)
In[1]:= f[t_] := Cos[t]
In[2]:= g[t_] := Sin[t]

In[27]:= list1 = Table[f[t], {t, 0, 2 Pi, .1}];
In[28]:= list2 = Table[g[t], {t, 0, 2 Pi, .1}];

In[29]:= n = Length[list1];
In[30]:= plotdat = Thread[{list1, list2}];
In[31]:= frame = ConstantArray[0.0, n];

In[32]:= Do[
  frame[[j]] =
   Show[ListLinePlot[plotdat[[1 ;; j]], PlotStyle -> {Red, Dashed},
     PlotRange -> {{-1.2, 1.2}, {-1.2, 1.2}}],
    ListPlot[plotdat[[1 ;; j]],
     PlotRange -> {{-1.2, 1.2}, {-1.2, 1.2}},
     PlotMarkers -> {Automatic, 12}]], {j, 1, n}]

In[33]:= ListAnimate[frame]





  • Prev by Date: Re: Jens-Peer Kuska passed away
  • Next by Date: Re: Re: Jens-Peer Kuska passed away
  • Previous by thread: Re: Animate parametric plot of two lists?
  • Next by thread: Manipulate not working