# How to plot several lists for different values of independent variable in a same graph?

How could I plot parameters Br and Dr for several values of t0 starting from -3 to 0 with step size 1 for the following ode? I was able to plot t0=-3 and want to plot other lists of parameter set {Br,Dr } derived from different points of t0 in the same graph.

ClearAll["Global*"];
t0 = -3; b = 2;

ode1 = y'[t] == -Sin[x[t]]/y[t];

ode2 = x'[t] == -Cos[x[t]] (6 Sin[x[t]] Cos[x[t]] + y[t] (b - c (1 + 3*y[t]^2)))/(2*
y[t]^3*(b + c (y[t]^2 - 1)));

ode3 = v'[t] == -(b + c*(y[t]^2 - 1))/(4*y[t]*Cos[x[t]]) + Sin[x[t]]/(2*y[t]^2);

bc = {x[t0] == 0, y[t0] == Br, v[t0] == Log[Dr]};
sol = ParametricNDSolve[{ode1, ode2, ode3, bc}, {x, y, v}, {t, t0,0}, {c, Br, Dr}]
data = Table[FindRoot[{(y[c, Br, Dr][0] - 1) /. sol, v[c, Br, Dr][0] /. sol}, {{Br,1}, {Dr, 1}}], {c, 0.3, 2.2, .05}];
Br = Br /. data; Dr = Dr /. data;

ListLinePlot[Thread[{Dr, ArrayResample[Br, Length@Dr]}],Frame -> True, FrameLabel -> {{"Br", ""}, {"Dr", ""}}]

• Do you mean to plot several data in one Plot? Sep 20, 2022 at 3:36
• I meant another set of Br and Dr data from the table for another values of t0 and show them altogether in a same graph. Sep 20, 2022 at 14:40

We can use Do loop as follows

ClearAll["Global*"];
b = 2;

ode1 = y'[t] == -Sin[x[t]]/y[t];

ode2 = x'[
t] == -Cos[
x[t]] (6 Sin[x[t]] Cos[x[t]] + y[t] (b - c (1 + 3*y[t]^2)))/(2*
y[t]^3*(b + c (y[t]^2 - 1)));

ode3 = v'[t] == -(b + c*(y[t]^2 - 1))/(4*y[t]*Cos[x[t]]) +
Sin[x[t]]/(2*y[t]^2);

bc = {x[t0] == 0, y[t0] == Br, v[t0] == Log[Dr]};

Do[t0 = -3 + i/2;
sols[i] =
ParametricNDSolve[{ode1, ode2, ode3, bc}, {x, y, v}, {t, t0, 0}, {c,
Br, Dr}];
dat[i] =
Table[{Br, Dr} /.
FindRoot[{(y[c, Br, Dr][0] - 1) /. sols[i],
v[c, Br, Dr][0] /. sols[i]}, {{Br, 1}, {Dr, 1}}] // Quiet, {c,
0.3, 2.2, .05}];
lst[i] =
ArrayResample[dat[i][[All, 1]], Length@dat[i]]}], {i, 0, 5, 1}]


Visualization

ListPlot[Table[lst[i], {i, 0, 5, 1}], Frame -> True,
FrameLabel -> {{"Br", ""}, {"Dr", ""}},
PlotLegends -> Table[Row[{"t0 =", -3. + i/2}], {i, 0, 5, 1}]]


• Thank you so much @Alex Trounev. This is what I was looking for. Sep 20, 2022 at 16:01
• You are welcome! Sep 20, 2022 at 16:03
• @Dibbo123 Question about solution mark is very advanced. Better to start new post. Maybe somebody has a good answer. Sep 22, 2022 at 15:18
• Thanks. I will do that. Sep 22, 2022 at 15:30