I'm working on a simulation where I've got a list of points (i.e. {{0, 0}, {1, 1}, ... , {10, 10}}). I'm trying to graph a differential equation on the same axes as the list of points. I know I have to Plot NDSolve to plot the differential equation and ListPlot on the list of points. How would I do both?

Let me know if you need more information. Thanks!


Next time, share complete information (DE's and data points).

Are you looking for something like this?

sol = NDSolve[{y'[t] == y[t], y[0] == 1}, y[t], {t, 0, 1}];

p1 = Plot[y[t] /. sol, {t, 0, 1}];

points = Table[{t, N@Exp[t]}, {t, 0, 1, 0.5}];

p2 = ListPlot[points, PlotStyle -> Red];

Show[{p1, p2}]

enter image description here

| improve this answer | |
  • 1
    $\begingroup$ Or just add the points to the Plot usingEpilog, e.g., Plot[y[t] /. sol, {t, 0, 1}, Epilog -> {Red, AbsolutePointSize[4], Point[points]}] $\endgroup$ – Bob Hanlon Apr 18 '18 at 15:14

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.