1
$\begingroup$

Writing:

p1 = ParametricPlot[{t, 0}, {t, 0, 1}, 
                     Axes -> False, 
                     PlotStyle -> Gray];
frames = {};
For[t0 = 1, t0 <= 2, t0 = t0 + 0.05,
    p2 = ParametricPlot[{t, 0}, {t, 0, t0}, 
                        Axes -> False, 
                        PlotStyle -> Green];
    frames = Join[frames, {Magnify[Show[{p1, p2}, 
                  PlotRange -> {{-2, 2}, {-2, 2}}], 1.5]}]
   ]
Export["prova1.gif", frames, "AnimationRepetitions" -> \[Infinity]];

I get:

enter image description here

that's what I want.

Instead, writing:

p1 = ParametricPlot3D[{t, 0, 0}, {t, 0, 1}, 
                       Axes -> False, 
                       Boxed -> False,
                       PlotStyle -> Gray];
frames = {};
For[t0 = 1, t0 <= 2, t0 = t0 + 0.05,
    p2 = ParametricPlot3D[{t, 0, 0}, {t, 0, t0}, 
                          Axes -> False, 
                          Boxed -> False,
                          PlotStyle -> Green];
    frames = Join[frames, {Magnify[Show[{p1, p2}, 
                  PlotRange -> {{-2, 2}, {-2, 2}, {-2, 2}}], 1.5]}]
   ]
Export["prova2.gif", frames, "AnimationRepetitions" -> \[Infinity]];

I get:

enter image description here

that is not as desired.

How can I fix it?

$\endgroup$
  • 2
    $\begingroup$ The two lines are partially in exactly the same place. It's not clear which should be shown, hence sometimes the gray is shown and sometimes the green. You need to give one of the lines a small offset (which doesn't have to be discernible to the human eye) so that it is clear which line is closer to the camera. $\endgroup$ – C. E. Feb 6 '19 at 10:23
  • 1
    $\begingroup$ Perfect, solved! Thank you! $\endgroup$ – TeM Feb 6 '19 at 11:03

Browse other questions tagged or ask your own question.