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: [mg101503] Re: [mg101475] Animate parametric plot of two lists?
  • From: Jaebum Jung <jaebum at wolfram.com>
  • Date: Thu, 9 Jul 2009 01:53:34 -0400 (EDT)
  • References: <200907081111.HAA12291@smc.vnet.net>

Porscha Louise McRobbie wrote:
> 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]
>
>
>   
You can interpolate data and use ParametricPlot (not sure it is more 
efficient than yours though).

{f1, f2} = ListInterpolation[#, {{0, 2 Pi}}] & /@ {list1, list2}

Animate[ParametricPlot[{f1[t], f2[t]}, {t, 0, max},
  PlotRange -> {-1.2, 1.2}, AspectRatio -> 1/GoldenRatio,
  Mesh -> {Range[0, 2 Pi, .1]}, PlotStyle -> Red,
  MeshStyle -> Directive[PointSize[Large], Blue]], {max, 0.1, 2 Pi}]



Jay


  • Prev by Date: Re: Manipulating list
  • Next by Date: Re: Re: Simplifying with KroneckerDelta
  • Previous by thread: Animate parametric plot of two lists?
  • Next by thread: Re: Animate parametric plot of two lists?