Message Boards Message Boards


Plot a graph of a non linear ODE system?

Posted 6 months ago
1 Reply
1 Total Likes

Hello everybody,

I got a simple question. I wrote this instruction to plot the solution of my non linear ODE system. The problem is that the program plots all the three functions in one color. How can I change it? Why doesn't it label them?

Thank you!


 (* Tested on Mathematica version 10.2 and 11.3 *)

 sol = NDSolve[{x'[t] == -y[t] - x[t]^2, y'[t] == 2 x[t] - y[t]^3, 
 z'[t] == 2 x[t] - z[t], x[0] == y[0] == z[0] == 1}, {x, y, z}, {t,10}];

Plot[Evaluate[{x[t], y[t], z[t]} /. sol], {t, 0, 10},
PlotLegends -> Placed[{"x[t]", "y[t]", "z[t]"}, Above]](*default colors*)

enter image description here

Plot[Evaluate[{x[t], y[t], z[t]} /. sol], {t, 0, 10}, PlotStyle -> {Red, Green, Blue}, 
PlotLegends -> Placed[{"x[t]", "y[t]", "z[t]"}, Above]]

enter image description here

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract