# Animated basic Vector plot

what codes are needed to properly animate a vector plot? this for example: VectorPlot[{y, -x}, {x, -3, 3}, {y, -3, 3}]. because i tried everything, i have read the help manual, and searched in youtube tutorials but i couldn't do it.

• What do you mean with animate? What do you want to animate? The vector field you gave is static the only thing there you could animate would be plot parameters or the field itself. Mathematica has the Animate and Manipulate function for this.
– N0va
Aug 30, 2016 at 21:48
• My teacher just told us to make a vector field 2D and 3D to move ("animate"), but i have never used mathematica before. Aug 30, 2016 at 21:50
• Look at the Documentation for Animate and put in your vector plot instead of the normal plot from the example. Then you just need to chose what quantity you want to animate. The field itself could be one option: Animate[VectorPlot[{y, u*x}, {x, -3, 3}, {y, -3, 3}], {u, -2, 2}]
– N0va
Aug 30, 2016 at 21:56
• thanks really, yes thats exactly what i didn't know how to do it. Aug 30, 2016 at 22:00
• Welcome to Mathematica.SE! I hope you will become a regular contributor. To get started, 1) take the introductory tour now, 2) when you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge, 3) remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign, and 4) give help too, by answering questions in your areas of expertise. Aug 30, 2016 at 22:25

Here is one possibility:

Clear[dx, dy, f, points, fmap, stages, stuff]

dx[x_, y_] := -9 y + (3 x^2 y)/4;
dy[x_, y_] := -9 x + x^3/4;
Clear[f]
f[{x_, y_}] := {0, 0} /; \[Not] (-10 <= x <= 10.1);
f[{x_, y_}] := {0, 0} /; \[Not] (-10 <= y <= 10.1);
f[{x_, y_}] := {x + .001 dx[x, y] , y + .001 dy[x, y]};

points = Partition[Table[RandomReal[{-4, 4}], 200], 2, 1]~Join~
Partition[Table[RandomReal[{-10, 10}], 200], 2, 1];

Clear[fmap];
fmap[{stuff___}] := f /@ {stuff};
stages = NestList[fmap, points, 100];
stages = stages /. {x_Real, y_Real} /; \[Not](-10 < x < 10) :>{0,0};

stuff = Show[StreamPlot[{-9 y + (3 x^2 y)/4, -9 x + x^3/4}, {x, -10, 10}, {y, -10, 10},
PlotTheme -> "Minimal"],
Graphics@{Red, PointSize[.015], Point[stages[[hh]]]},
PlotRange -> {{-10, 10}, {-10, 10}}
, Axes -> True]~Table~{hh, 1, 100, 1};

ListAnimate[stuff]  idea2

 Manipulate[
VectorPlot[{y - p[], x + p[]}, {x, -3, 3}, {y, -3, 3}],
{{p, {0, 0}}, Locator}]

Clear[dx, dy, f, points, fmap, stages, stuff]

dx[x_, y_] := y^3 - 9 x ;
dy[x_, y_] := x^3 - 9 y ;

f[{x_, y_}] := {0, 0} /; \[Not] (-10 <= x <= 10.1);
f[{x_, y_}] := {0, 0} /; \[Not] (-10 <= y <= 10.1);
f[{x_, y_}] := {x + .001 dx[x, y], y + .001 dy[x, y]};

points = Partition[Table[RandomReal[{-4, 4}], 200], 2, 1]~Join~
Partition[Table[RandomReal[{-10, 10}], 200], 2, 1];

fmap[{stuff___}] := f /@ {stuff};
stages = NestList[fmap, points, 100];
stages = stages /.{x_Real, y_Real} /; \[Not] (-10 < x < 10) :> {0,0};

stuff = Show[
StreamPlot[
{    y^3 - 9 x   ,     x^3 - 9 y  },
{x, -10, 10},
{y, -10, 10},
PlotTheme -> "Minimal"
],
Graphics@{Red, PointSize[.015], Point[stages[[hh]]]},
PlotRange -> {{-10, 10}, {-10, 10}},
Axes -> True
]~Table~{hh, 1, 100, 1};

ListAnimate[stuff]

• maybe change the points to vectors will have a better visual effect :) very impressive! +1
– Wjx
Aug 30, 2016 at 23:42
• good idea! I will try to do that. @Wjx Aug 31, 2016 at 20:38
• Also, you can ramdomly generate points in the animation process, so the dynamic can keep going.
– Wjx
Aug 31, 2016 at 22:20
• falstad.com/vector probably the best simulation on the internet Aug 15, 2019 at 17:21
• another nice javascript simulation anvaka.github.io/fieldplay Aug 15, 2019 at 22:21