I use Mathematica to draw the displacement, velocity, and acceleration of one point in a graphic.
FinalGraphics[Joint_, plotRange_List, opt_String] :=
Module[{JointDisplacement, JointVelocity, JointAccelaration},
JointDisplacement = Plot[Joint, {t, plotRange[[1, 1]], plotRange[[1, 2]]}];
JointVelocity =
Plot[Evaluate @ D[Joint, t], {t, 0, 5}, PlotStyle -> {Black, Dashed}];
JointAccelaration =
Plot[Evaluate @ D[Joint, {t, 2}], {t, 0, 5}, PlotStyle -> {Thick, Orange, Dashed}];
Column[{
Show[{JointDisplacement, JointVelocity, JointAccelaration},
AxesLabel -> {Style["t(s)", 15], ""},
AxesStyle -> Arrowheads[.04],
PlotRange -> plotRange,
ImageSize -> 450,
GridLines -> {None, Automatic}], opt},
Center]]
Now I use my function:
Joint1 =
-0.609735 + 0.0436332 t^2 + 0.0327806 t^3 - 0.0133248 t^4 + 0.00120561 t^5;
FinalGraphics[Joint1, {{0, 5}, {-.6, .5}}, "Graphic5.1 the displacement, velocity, acceleration of joint1"]
However, the above graphic lacks plotlegends, so I rewrite my code:
Needs["PlotLegends`"]
FinalGraphicsLegend[Joint_, plotRange_List] :=
Module[{},
Plot[{Joint, Evaluate @ D[Joint, t], Evaluate @ D[Joint, {t, 2}]},
{t, plotRange[[1, 1]], plotRange[[1, 2]],
PlotLegend -> {"displacement", "velocity", "acceleration"}}]]
but it fails.
FinalGraphicsLegend[Joint1, {{0, 5}, {-.6, .5}}]
General::ivar: 0.00010214285714285715` is not a valid variable. >>
So my question is:
How do I correct the function FinalGraphicsLegend
or add plot legends to the function FinalGraphic
in some other way?
FinalGraphicsLegend[Joint_, plotRange_List] := Module[{}, Plot[{Joint, Evaluate@D[Joint, t], Evaluate@D[Joint, {t, 2}]}, {t, plotRange[[1, 1]], plotRange[[1, 2]]}, PlotLegend -> {"displacement", "velocity", "acceleration"}, Evaluated -> True]]
$\endgroup$autoLegend
function defined in the first code block of my answer here and write theColumn
like this:Column[{Show[autoLegend[Show[{JointDisplacement, JointVelocity, JointAccelaration}, AxesLabel -> {Style["t(s)", 15], ""}, AxesStyle -> Arrowheads[.04], PlotRange -> plotRange, GridLines -> {None, Automatic}], {"displacement", "velocity", "acceleration"}], ImageSize -> 450], opt}]
$\endgroup$