4
$\begingroup$

So, I have the code

Export["vectors.gif",
  Animate[
   Graphics[
     {White,Arrow[{{0, 0}, {a,b}}]}, 
     GridLines->Automatic,Axes->True,Background->Black, 
     PlotRange->5], 
  {a, -2, 2,0.25},{b,-2,2,0.25}, AnimationRepetitions->1]]

but it just exported an image of an instant of the animation. How do I export the full animation?

EDIT: Okay, new problem. Using the code

Export["vectors.gif", 
Table[Graphics[{White, Arrow[{{0, 0}, {a, b}}]}, 
GridLines -> Automatic, Axes -> True, Background -> Black, 
PlotRange -> 5], {a, -2, 2, 0.25}, {b, -2, 2, 0.25}]]

exports an animation, but it looks kind of strange. It gives a bunch of smaller images it animates - like it is taking each value of one variable and animating the second variable across it, if that makes sense. It doesn't give one coherent image.

Thanks!

$\endgroup$

closed as off-topic by Wjx, corey979, Feyre, Ajasja, happy fish Oct 2 '16 at 16:31

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Wjx, corey979, Feyre, Ajasja, happy fish
If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\begingroup$ But, an animation is supposed to be a flat list of images; why are you feeding a matrix of images to the exporter? $\endgroup$ – J. M. is away Oct 2 '16 at 12:56
  • $\begingroup$ Export this instead: Table[Graphics[{White, Arrow[{{0, 0}, {a, a}}]}, GridLines -> Automatic, Axes -> True, Background -> Black, PlotRange -> 5], {a, -2, 2, 0.25}]. $\endgroup$ – bbgodfrey Oct 2 '16 at 12:57
  • $\begingroup$ @bbgodfrey, thank you! Now it gives a single coherent image. Strangely enough, though, the arrow isn't rotating around the origin like I thought it would; just going diagonally in a straight line and flipping directions. Not sure why. $\endgroup$ – heather Oct 2 '16 at 13:00
  • $\begingroup$ Try Table[Graphics[{White, Arrow[{{0, 0}, {2 Cos[c], 2 Sin[c]}}]}, GridLines -> Automatic, Axes -> True, Background -> Black, PlotRange -> {{-5, 5}, {-5, 5}}], {c, -3 Pi/4, Pi/4, Pi/8}] $\endgroup$ – bbgodfrey Oct 2 '16 at 13:07
  • $\begingroup$ @bbgodfrey, that gives just the image again when exported, like my original code. $\endgroup$ – heather Oct 2 '16 at 13:08
1
$\begingroup$

Export the following to obtain the desired file

Table[Graphics[{White, Arrow[{{0, 0}, 2 Sqrt[2] {Cos[c], Sin[c]}}]}, 
    GridLines -> Automatic, Axes -> True, Background -> Black, 
    PlotRange -> {{-5, 5}, {-5, 5}}], {c, -3 Pi/4, Pi/4, Pi/8}]
$\endgroup$
9
$\begingroup$

You should export just the List, not the object created by Animate. For this, Table is a good idea.

Export["vectors.gif", 
Table[Graphics[{White, Arrow[{{0, 0}, {a, b}}]}, 
GridLines -> Automatic, Axes -> True, Background -> Black, 
PlotRange -> {{-5, 5}, {-5, 5}}], {a, -2, 2, 0.25}, {b, -2, 2, 0.25}]]

On the other hand: You seem to have two animation variables. What is the meaning of this? Should they be varying simultaneously? If so, just get rid of b and change the Arrow to point to {a,a}. If not, could you please clarify?

$\endgroup$
  • 1
    $\begingroup$ Thanks for pointing that out - yes, it can just be {a,a}. $\endgroup$ – heather Oct 2 '16 at 1:53
  • $\begingroup$ Okay, this works, but a little oddly. After looking at the result, it gives a bunch of smaller images it animates - like it is taking each value of one variable and animating the second variable across it, if that makes sense. It doesn't give one coherent image. $\endgroup$ – heather Oct 2 '16 at 12:28
  • $\begingroup$ Yes, because you're animating over two variables as it stands. Time only has one direction, after all, so the animation is making one frame for each a value and then animating them all through the b values (or vice versa). There is no way to have it animate two variables independently; the only actual parameter in a gif is the frame number. $\endgroup$ – Ben Kalziqi Oct 2 '16 at 14:50

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