0
$\begingroup$

I'm trying to create a list of "snapshots" of the function ListPolarPlot to create a exportable gif or animation. My attempt is somewhat taken from this answer. The idea is to create this list of "snapshots" and then use the function ListAnimation to create the movie.

enter image description here

However, it gives the below error. My goal is to create a exportable gif or animation of this plot

enter image description here

The inputs theta and polarray are lists of angular and radial coordinates in polar coords, respectfully. They represent a numerical approximation of time-dependent planetary motion.

All suggestions would be greatly appreciated! Thank you in advance for any help!

$\endgroup$
  • 1
    $\begingroup$ Where are θ and polarray? $\endgroup$ – J. M. will be back soon Sep 10 '17 at 4:13
  • $\begingroup$ They're the inputs for making the plot. They're just simple lists of doubles. EDIT: I suspect my issue is almost certainly that I poorly understand how to implement pure functions using #, &, @ etc. $\endgroup$ – JeremyPenn Sep 10 '17 at 4:14
  • $\begingroup$ try replacing & /@ {theta, polarray} with & @@@ {theta, polarray} $\endgroup$ – Jason B. Sep 10 '17 at 4:34
  • $\begingroup$ It θ and polararray are lists, you could replace {#1, #2} with {#[[1]], #[[2]]}, and {θ, polararray} with Transpose[{θ, polararray}]. $\endgroup$ – aardvark2012 Sep 10 '17 at 4:38
2
$\begingroup$

Since the OP was unable/unwilling to produce the θ and polarray lists, I'm making my own:

orbit[θ_] = With[{a = QuantityMagnitude[PlanetData["Earth", "SemimajorAxis"]],
                  b = QuantityMagnitude[PlanetData["Earth", "SemiminorAxis"]]}, 
                 b^2/(a + Sqrt[a^2 - b^2] Cos[θ])]

θList = N[Range[0, π/2, π/32]];
rList = orbit[θList];

From there:

data = Transpose[{θList, rList}];
frames = Table[ListPolarPlot[Take[data, k], Axes -> None, Frame -> True, 
                             PlotMarkers -> Style["×", Large], 
                             PlotRange -> {{0, 1}, {0, 1}}, PlotStyle -> ColorData[97, 2]],
               {k, Length[data]}];
ListAnimate[frames]

some cartoon

$\endgroup$
  • $\begingroup$ Thank you! This is exactly what I needed! $\endgroup$ – JeremyPenn Sep 10 '17 at 16:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.