1
$\begingroup$

I am trying to plot these graphics together. I tried with Plot and Show command but it doesn't work. Please help!

sol2 = NDSolve[{0.0099 u'[t] == v[t] - u[t]*v[t] + u[t] - 2 u[t]^2, 
   2.4892*10^(-5)*v'[t] == -v[t] - (u[t])*v[t] + 0.45*3, u[0] == 0.1, 
   v[0] == 0.2}, {u[t], v[t]}, {t, 0, 50}]
q1 = Plot[u[t] /. sol2, {t, 0, 1}, PlotStyle -> Red]
q2 = Plot[v[t] /. sol2, {t, 0, 1}, PlotStyle -> Blue]
Show[{q1, q2}]
$\endgroup$
  • $\begingroup$ It is actually working, the only issue is that the plot range for the Show command comes from the first plot. If you use Show[q1, q2, PlotRange -> {0.68, 0.81}] you should see both plots. However, they look like flat lines because the plot ranges are so different (look at the y-axis of the plots for q1 and q2). $\endgroup$ – MassDefect Nov 24 '19 at 19:34
  • $\begingroup$ Thanks! Actually they are not so different - they are in the range (0.6,0.8). I cannot understand why the graphs are straight lines. $\endgroup$ – Ксения Цочева Nov 24 '19 at 20:02
  • $\begingroup$ Look closely at the plot ranges of the individual plots. $\endgroup$ – Bob Hanlon Nov 24 '19 at 20:17
  • $\begingroup$ The height of each graph is like 0.00001. When you scale the graph to show from 0.6 to 0.8, the height of each curve becomes very very small. $\endgroup$ – MassDefect Nov 25 '19 at 3:09
2
$\begingroup$

There is not a one-size-fit-all solution for this, I think.

If you are more interested in comparing those functions on the same scale:

q1 = Plot[u[t] /. sol2, {t, 0, 1}, PlotStyle -> Red, PlotRange -> All];
q2 = Plot[v[t] /. sol2, {t, 0, 1}, PlotStyle -> Blue, 
   PlotRange -> All];
Show[{q1, q2}, PlotRange -> Full, ImageSize -> Scaled[0.6]]

If you are interested in fine structure of those functions then this representation should be more helpful:

q1 = Plot[
   u[t] /. sol2, {t, 0, 1}
   , PlotStyle -> Red
   , ImagePadding -> {{45, 45}, {20, 0}}
   , Frame -> {True, True, True, False}
   , FrameStyle -> {Automatic, Red, Automatic, Automatic}
   , ImageSize -> Scaled[0.6]
   ];
q2 = Plot[
   v[t] /. sol2, {t, 0, 1}
   , PlotStyle -> Blue
   , ImagePadding -> {{45, 45}, {20, 0}}
   , Frame -> {False, False, False, True}
   , FrameTicks -> {{None, All}, {None, None}}
   , FrameStyle -> {Automatic, Automatic, Automatic, Blue}
   , ImageSize -> Scaled[0.6]
   ];
Overlay[{q1, q2}]

$\endgroup$

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.