0
$\begingroup$

Hi I can Plot the result of an NDSolve (toy example), but I cannot ParametricPlot it.

sol = NDSolve[{s'[t] == -s[t], i'[t] == -s[t], s[0] == 1, 
    i[0] == .1}, {s[t], i[t]}, {t, 0, 2}] ;

Plot[{  s[t] /. sol, i[t] /. sol}, {t, 0, 2}]
ParametricPlot[{  s[t] /. sol, i[t] /. sol}, {t, 0, 2}]
$\endgroup$
0
$\begingroup$

Finally, just adding Evaluate does it

ParametricPlot[Evaluate[{  s[t], i[t]} /. sol], {t, 0, 2}]

Still, I would like to understand why that is required with ParametricPlot but not with Plot

$\endgroup$
2
  • 1
    $\begingroup$ I believe you should execute the argument of ParametricPlot in each to see the difference. I think you’ll find that the code in the question does not have the form of xy coordinates. (In the docs, they sometimes use First[sol] instead of sol for this reason.) $\endgroup$ – Michael E2 Jun 14 at 4:31
  • 1
    $\begingroup$ ParametricPlot[{s[t], i[t]} /. sol, {t, 0, 2}] or ParametricPlot[{s[t] /. sol[[1]], i[t] /. sol[[1]]}, {t, 0, 2}] $\endgroup$ – cvgmt Jun 14 at 8:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.