In the post Use Mathematica to plot the flow of an ODE with discontinuity, the following ODE with discontinuous coefficient was solved

T = 1;
Y = ParametricNDSolveValue[{X'[t] == Boole[X[t] > 0], X[0] == x}, X, {t, 0, T}, {x}];
  ParametricPlot[{Y[x][t], t}, {t, 0, T}],
  {x, -1, 1, 0.1}
 PlotRange -> All,
 AxesLabel -> {"x", "t"}

I also wish to plot an additional family of solutions displayed in green in the picture below.

  • How can a plot just like the one below (but possibly with the t axis being the vertical one) be done starting from the code above?

  • Also, is it possible to have the "first" (x=t) and the "last" (x=0) of the green lines displayed in a different color (for example, blue instead of green)?

enter image description here


I'm not sure I understood, but if you only need to add some lines to existing plot from cited question:

T = 10;
Y = ParametricNDSolveValue[{X'[t] == Boole[X[t] > 0], X[0] == x}, 
   X, {t, 0, T}, {x}];
Show[Plot[{x, x + Range[10]}, {x, 0, 10}, 
  PlotRange -> {{-10, 10}, {0, 10}}, PlotStyle -> {Blue, Green}], 
 Table[ParametricPlot[{Y[x][t], t}, {t, 0, T}, PlotStyle -> Red], {x, 
   Complement[Range[-10, 10, 1], {0}]}], 
 Graphics[{Blue, Line[{{0, 0}, {0, 10}}]}], FrameLabel -> {"x", "t"}, 
 Frame -> True, Axes -> False]

enter image description here

  • $\begingroup$ Thank you. It looks very nice. By the way, is it possible to make the axis labels and the numbers a little bigger? $\endgroup$ – Riku Jan 3 '20 at 18:21
  • $\begingroup$ Yes, you can add option like FrameStyle -> Directive[FontSize -> 16, Black] with font size you need, and also you may increase image size with ImageSize option. $\endgroup$ – Alx Jan 4 '20 at 0:44

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.