# Aligning points in different plots [closed]

I am trying to get the red dot track vertically the green point on the graph, but they are different plots. And because of this I am experiencing difficulty.

There is a technique best to do this?

There is something about Piecewise, but didn't know how to apply.

velcarro = 69.2
dist1 = 8.4
time1 = 8.4/69.2
dist2 = 1.9
time2 = 27/60 // N
carro = {time1, dist1}
andando = {time2, dist2}
final = {time1 + time2, dist1 + dist2}

f[xP2_] := Evaluate[Fit[{{0, 0}, final}, {1, xP2}, xP2]];
xP2 = Subdivide[0, final[], 30];
yP2 = f[#] & /@ xP2;
coordP2 = Transpose[{xP2, yP2}];

Table[
Show[{
Plot[
Evaluate[Fit[{{0, 0}, carro}, {1, x}, x]],
{x, 0, time1},
PlotStyle -> {Directive[Red, Thickness[0.005]]}
],
Plot[
Evaluate[Fit[{carro, final}, {1, x}, x]],
{x, time1, final[]},
PlotRange -> {{final[], 0}, {0, final[]}},
PlotStyle -> {Directive[Red, Thickness[0.005]]}
],
Plot[
Evaluate[Fit[{{0, 0}, final}, {1, x}, x]],
{x, 0, final[]},
PlotStyle -> {Directive[Dashed, Green, Thickness[0.005]]}
],
p1 = Graphics[{Red, PointSize[0.03], Point[{0, 0}]}],
p2 = Graphics[{Green, PointSize[0.03], Point[#]}]
},
PlotRange -> {{0, final[]}, {0, final[]}}], 1
] & /@ coordP2 • And how to eliminate { and } of my animation? Oct 3, 2016 at 15:58
• The coordinates of your red Point don't change with the function argument Oct 3, 2016 at 18:16

Clear["Global*"]
velcarro = 69.2;
dist1 = 8.4;
time1 = 8.4/69.2;
dist2 = 1.9;
time2 = 27/60 // N;
carro = {time1, dist1};
andando = {time2, dist2};
final = {time1 + time2, dist1 + dist2};

g1 = Plot[Evaluate[Fit[{{0, 0}, carro}, {1, x}, x]], {x, 0, time1},
PlotStyle -> {Directive[Red, Thickness[0.005]]}];

g2 = Plot[Evaluate[Fit[{carro, final}, {1, x}, x]], {x, time1, final[]},
PlotRange -> {{final[], 0}, {0, final[]}},
PlotStyle -> {Directive[Red, Thickness[0.005]]}];

g3 = Plot[Evaluate[Fit[{{0, 0}, final}, {1, x}, x]], {x, 0, final[]},
PlotStyle -> {Directive[Dashed, Green, Thickness[0.005]]}];

t = Subdivide[0, final[], 30];

xPointG[x_] := Evaluate[Fit[{{0, 0}, final}, {1, x}, x]];

yPointG = xPointG[#] & /@ t;

coordPointG = Transpose[{t, yPointG}];

xPointV1[x_] := Evaluate[Fit[{{0, 0}, carro}, {1, x}, x]];

yPointV1 = xPointV1[#] & /@ Take[t, 7];

coordPointV1 = Transpose[{Take[t, 7], yPointV1}];

xPointV2[x_] := Evaluate[Fit[{carro, final}, {1, x}, x]];

yPointV2 = xPointV2[#] & /@ Take[t, {8, -1}];

coordPointV2 = Transpose[{Take[t, {8, -1}], yPointV2}];

coordPointV = Join[coordPointV1, coordPointV2];

pV = Graphics[{Red, PointSize[0.03], Point[#]}] & /@ coordPointV;

pG = Graphics[{Green, PointSize[0.03], Point[#]}] & /@ coordPointG;

frames = Flatten @@Table[
Show[{g1, g2, g3, pV[[#]], pG[[#]]},
PlotRange -> {{0, final[]}, {0, final[]}}], 1] & /@
Range[Length[t]];

Export["C:\\Users\\LMC\\moviment.gif", frames];
` 