# How to plot phase portiere and the solutions of ODES

Dear All I know how to plot phase portrait for the system of nonlinear odes

but I did not know whey the result of Show the parametric solutions with phase portiere not good

I Wrote the code as following:

sol[{N0_, I0_}?NumericQ] :=
First@NDSolve[{N1'[t] ==
r N1[t] (1 - \[Beta] N1[t]) - \[Eta] N1[t] I1[t],
I1'[t] == \[Sigma] + (\[Rho] N1 [t] I1[t])/(
m + N1[t]) - \[Delta] I1[t] - \[Mu] N1[t] I1[t], N1[0] == N0,
I1[0] == I0}, {N1, I1}, {t, 0, 365}];
P1 = ParametricPlot[
Evaluate[{N1[t], I1[t]} /. sol[#] & /@ Range[0, 2, 0.1]], {t, 0,
30}, PlotRange -> All, AspectRatio -> Full, PlotRange -> Full,
Frame -> True, MaxRecursion -> 8]


where

r = 0.431201; \[Beta] = 2.99 *10^-6;
\[Eta] = 0.2 ; \[Sigma] = 0.7; \[Rho] = 0.003; m = 0.427;  \[Delta] = \
0.57; \[Mu] = .82;


and I used StreamPlot as following:

f[N1_, I1_] = r N1 (1 - \[Beta] N1) - \[Eta] N1 I1;
g[N1_, I1_] = \[Sigma] + (\[Rho] N1 I1)/(
m + N1) - \[Delta] I1 - \[Mu] N1 I1;
G[{N1_, I1_}] = {f[N1, I1], g[N1, I1]};


then

StreamPlot[{f[N1, I1], g[N1, I1]}, {N1, 0, 30}, {I1, 0, 30},
StreamStyle -> Blue, AspectRatio -> Automatic, Frame -> True,
Axes -> False, AxesLabel -> {"N1", "I1"}]

Show[StreamPlot[{f[N1, I1], g[N1, I1]}, {N1, 0, 30}, {I1, 0, 30},
StreamPoints -> Fine, StreamStyle -> Blue, AspectRatio -> 1/2,
Frame -> True, AxesLabel -> {"N1", "I1"}, StreamPoints -> Fine,
PlotRange -> All], P1]


the finale result was,

can any one help me to improve my result? it was worked before I submitted the question and got the result above. my aim is plotting solutions of the system with different initial conditions and show the them with phase portrait.

• Hi Sana, your code does not produce the results you posted. Could you check that they're correct? A couple problems I see: 1) ?NumericQ is applied to a list and 2) you call sol with only a number not a list in the ParametricPlot. Commented Nov 26, 2018 at 4:23
• welcome @chris K i used the same steps with other system and it worked as well and get this result Commented Nov 26, 2018 at 4:28

r = 0.431201; \[Beta] = 2.99*10^-6;
\[Eta] = 0.2; \[Sigma] = 0.7; \[Rho] = 0.003; m = 0.427; \[Delta] = \
0.57; \[Mu] = .82;
n = ParametricNDSolveValue[{N1'[t] ==
r N1[t] (1 - \[Beta] N1[t]) - \[Eta] N1[t] I1[t],
I1'[t] == \[Sigma] + (\[Rho] N1[t] I1[t])/(m +
N1[t]) - \[Delta] I1[t] - \[Mu] N1[t] I1[t], N1[0] == N0,
I1[0] == I0}, N1, {t, 0, 365}, {N0, I0}];
i = ParametricNDSolveValue[{N1'[t] ==
r N1[t] (1 - \[Beta] N1[t]) - \[Eta] N1[t] I1[t],
I1'[t] == \[Sigma] + (\[Rho] N1[t] I1[t])/(m +
N1[t]) - \[Delta] I1[t] - \[Mu] N1[t] I1[t], N1[0] == N0,
I1[0] == I0}, I1, {t, 0, 365}, {N0, I0}];
P = Flatten[
Table[ParametricPlot[{n[x, y][t], i[x, y][t]}, {t, 0, 30},
PlotRange -> {{0, 5}, {0, 2}}, Frame -> True, MaxRecursion -> 8,
AspectRatio -> 1, FrameLabel -> {"N1", "I1"},
PlotStyle -> Blue], {x, 0, 2, 0.2}, {y, 0, 2, .2}]];

f[N1_, I1_] = r N1 (1 - \[Beta] N1) - \[Eta] N1 I1;
g[N1_, I1_] = \[Sigma] + (\[Rho] N1 I1)/(m +
N1) - \[Delta] I1 - \[Mu] N1 I1;
G[{N1_, I1_}] = {f[N1, I1], g[N1, I1]};

P1 = StreamPlot[{f[N1, I1], g[N1, I1]}, {N1, 0, 5}, {I1, 0, 2},
AspectRatio -> 1, Frame -> True, Axes -> False,
StreamStyle -> Gray, StreamPoints -> Fine];

Show[P, P1]


To display the points at different scales use the code

point = {{0., 1.2280701754385965}, {1.4649020816028147,
0.4905006385109145}, {334447.8852, 0}};
g1 = Graphics[{Red, PointSize[.05], Point[point]},
Frame -> False]; P =
Flatten[Table[
ParametricPlot[{n[x, y][t], i[x, y][t]}, {t, 0, 30},
PlotRange -> {{-1, 5}, {0, 2}}, Frame -> True, MaxRecursion -> 8,
AspectRatio -> 1, FrameLabel -> {"N1", "I1"},
PlotStyle -> Blue], {x, -1, 2, 0.2}, {y, 0, 2, .2}]]; P1 =
StreamPlot[{f[N1, I1], g[N1, I1]}, {N1, -1, 5}, {I1, 0, 2},
AspectRatio -> 1, Frame -> False, Axes -> False,
StreamStyle -> Gray, StreamPoints -> Fine]; s1 = Show[P, P1]
P2 = Flatten[
Table[ParametricPlot[{n[x, y][t], i[x, y][t]}, {t, 0, 30},
PlotRange -> {{334446, 334449}, {-1, 2}}, Frame -> True,
MaxRecursion -> 8, AspectRatio -> 1, FrameLabel -> {"N1", "I1"},
PlotStyle -> Blue, Axes -> False], {x, 334446, 334449,
0.3}, {y, -1, 2, .2}]];

P3 = StreamPlot[{f[N1, I1], g[N1, I1]}, {N1, 334446, 334449}, {I1, -1,
2}, AspectRatio -> 1, Frame -> False, Axes -> False,
StreamStyle -> Gray, StreamPoints -> Fine]; s2 = Show[P2, P3]
{Show[s1, g1], Show[s2, g1]}


• Yes, i aim to get this result, Thankful @Alex Trounev Commented Nov 27, 2018 at 3:14
• I try to add the list of the points on the graph but the result not fine, can you help me ListPlot[{{0., 1.2280701754385965}, {1.4649020816028147 , 0.4905006385109145},{334447.8852, 0}}, PlotStyle -> {Red, (PointSize /@ {Small, Medium, Large})}] I succeed to add the first two points only and add the third point in the separate graph but the result not fine. @Alex Trounev Commented Feb 27, 2019 at 8:34
• The third point can not fit because it does not fall into PlotRange -> {{0, 5}, {0, 2}}. What is the need to show this point? Commented Feb 27, 2019 at 12:22
• yah, I want to show the solution is stable around this point, I plot it in the new figure and change the range of plot to include the third point but the size of the point is small how can make it larger @Alex Trouneve Commented Feb 27, 2019 at 13:59
• sorry I do not know how to submit the figure here. Commented Feb 27, 2019 at 14:06