I wrote the following code for create an animation with legend: however I was not able to put the LineLegend command into the command Animate and so it seems that this is the reason for which I can't export the animation in a gif-animation. So I'd like know how create a legend for an animation and how put it in a specific position and so finally how export it: I point out that I have to export a row animation if possible. So to follow the code
Subscript[x, 0][j_] := 1 (*Ascissa iniziale del j-esimo punto*)
Subscript[y, 0][j_] := j(*Ordinata iniziale del j-esimo punto*)
x[t_, j_] :=
Subscript[x, 0][
j] (t^2 +
1)(*Legge orraria del j-esimo punto sull'asse delle ascisse*)
y[t_, j_] :=
Subscript[y, 0][
j] (t + 1)(*Legge oraria del j-esimo punto sull'asse delle \
ordinate*)
T[t_, j_] := {x[t, j], y[t, j]}(*Traiettoria del j-esimo punto*)
Color = {Red, Green, Blue};(*Lista colori*)
Trajectory[j_, i_, r_, g_, b_, o_, s_] :=
Piecewise[{{ParametricPlot[T[t, j], {t, 0, i}, ImageSize -> Large,
AspectRatio -> 1, PlotStyle -> Extract[Color, j]],
s == 0}, {ParametricPlot[T[t, j], {t, 0, i}, ImageSize -> Large,
AspectRatio -> 1,
PlotStyle -> {RGBColor[r, g, b], Directive[Opacity[o]]}],
s == 1}}]
P[t_, j_] := {PointSize[0.01], Point[T[t, j]]}(*Punto j-esimo*)
V[t_, j_] = {Arrowheads[0.03],
Arrow[{T[t, j],
T[t, j] + {D[x[t, j], t],
D[y[t, j],
t]}}]};(*Vettore velocità della j-esima traiettoria al tempo \
t*)
MotionPoints[n_, i_] :=
Legended[Animate[
Show[Table[Trajectory[j, i, 0, 0, 0, 0, 0], {j, n}],
Graphics[Table[{ V[t, j], P[t, j]}, {j, n}]],
PlotRange -> {{0, 35}, {0, 35}}], {t, 0, i},
AnimationRate -> 0.3, AnimationRunning -> True],
Placed[LineLegend[{Red, Green,
Blue}, {"Traiettoria \!\(\*SubscriptBox[\(P\), \
\(1\)]\)=(1,1,0)",
"Traiettoria \!\(\*SubscriptBox[\(P\), \(2\)]\)=(1,2,0)",
"Traiettoria \!\(\*SubscriptBox[\(P\), \(3\)]\)=(1,3,0)"},
LegendLabel -> Placed["TRAIETTORIE", Above],
LegendFunction -> "Frame"], Below]];(*Animazione del moto*)
\[Xi][s_, t_, j_] := Exp[(2 t s)/(t^2 + 1) + Log[x[t, j]]]
\[Eta][s_, t_, j_] := Exp[s/(t + 1) + Log[y[t, j]]]
\[CapitalLambda][s_, t_,
j_] := {\[Xi][s, t, j], \[Eta][s, t,
j]}(*Linea di corrente del punto j-esimo all'istante t*)
Streakline[t_, j_] :=
Piecewise[{{ParametricPlot[\[CapitalLambda][s, t, j], {s, 0, 3},
PlotRange -> {{-10, 10}, {-10, 10}}, ImageSize -> Large,
AspectRatio -> 1,
PlotStyle ->
RGBColor[0.98, 0.85, 0.37]], (t - 0)*(t - 1)*(t - 2) !=
0}, {ParametricPlot[\[CapitalLambda][s, t, j], {s, 0, 3},
PlotRange -> {{-10, 10}, {-10, 10}}, ImageSize -> Large,
AspectRatio -> 1,
PlotStyle ->
Piecewise[{{Red, t == 0}, {Green, t == 1}, {Blue,
t == 2}}]], (t - 0)*(t - 1)*(t - 2) == 0}}]
StreaklineMotion[j_, i_] :=
Legended[Animate[
Show[Table[Streakline[h - 1, j], {h, 3}],
Trajectory[j, i, 0, 0, 0, 0.5, 1], Streakline[t, j],
Graphics[{ V[t, j], P[t, j]}],
PlotRange -> {{0, 35}, {0, 35}}], {t, 0, i},
AnimationRate -> 0.12, AnimationRunning -> True],
Placed[LineLegend[{Red, Green, Blue,
RGBColor[0.98, 0.85,
0.37]}, {"Linea di corrente di \!\(\*SubscriptBox[\(P\), \(1\)]\
\) al tempo t=0",
"Linea di corrente di \!\(\*SubscriptBox[\(P\), \(1\)]\) al \
tempo t=1 ",
"Linea di corrente di \!\(\*SubscriptBox[\(P\), \(1\)]\) al \
tempo t=2",
"Linea di corrente di \!\(\*SubscriptBox[\(P\), \(1\)]\) al \
tempo t"},
LegendLabel ->
Placed["LINEE DI CORRENTE DI \!\(\*SubscriptBox[\(P\), \
\(1\)]\)=(1,1,0)", Above], LegendFunction -> "Frame"],
Below]](*Animazione linee di corrente del j-esimo punto*)
Row[{MotionPoints[3, 5], , , , StreaklineMotion[1, 2]}]
So could someone help me, please?
Below
with{0.5, 0.7}
for both legends. p.s. your code does not compute, but I think it is computing at your end just fine. EDIT: It could be version dependent. I have 12.2.0. Animation is running but inside a red box. $\endgroup$m = Animate[ Legended[ Show[Table[Trajectory[j, i, 0, 0, 0, 0, 0], {j, n}], Graphics[Table[{V[t, j], P[t, j]}, {j, n}]], PlotRange -> {{0, 35}, {0, 35}}], Placed[LineLegend[{Red, Green, Blue}, {"Traiettoria \!\(\*SubscriptBox[\(P\), \ \(1\)]\)=(1,1,0)", "Traiettoria \!\(\*SubscriptBox[\(P\), \(2\)]\)=(1,2,0)", "Traiettoria \!\(\*SubscriptBox[\(P\), \(3\)]\)=(1,3,0)"}, LegendLabel -> Placed["TRAIETTORIE", Above], LegendFunction -> "Frame"], {0.5, 0.7}]], {t, 0, i}, AnimationRate -> 0.3, AnimationRunning -> True];
$\endgroup$Export["C:\\test.gif", m]
and the same thing forn
or similar variable. Use a quick time player to see the animation or similar. $\endgroup$