# Plot all curves in a table with a single color

I want all of my solutions in a table to be the same color. My attempt:

sol = DSolveValue[y'[t] == -2/t*y[t] + 4 t, y[t], t];
tbl = Table[sol /. C -> C, {C, -1, 1, 0.25}];
Plot[tbl, {t, -2, 2}, PlotStyle -> {Thick, Blue}]


produces: Is there a simple way to make all curves blue?

PlotStyle -> {{Thick, Blue}}


You have a set of nine separate graphs, and PlotStyle applies each element in its list to subsequent graphs. Thus if you put PlotStyle -> {Thick, Blue}, Mathematica applies Thick to the first graph, Blue to the second graph, Thick to the third, Blue to the fourth, and so on. But if you set PlotStyle -> {{Thick, Blue}}, there is only one (compound) element in the list, so Mathematica keeps applying it to every graph.

• I learned a lot from this answer. – David Jan 31 '15 at 4:57
Plot[tbl, {t, -2, 2}, PlotStyle-> Directive[Thick,Blue]] (* or Directive[{Thick,Blue}] *) • Aha! Interesting. There is obviously a difference in the way PlotStyle->{Thick,Blue} and PlotStyle->Directive[Thick,Blue] perform. David Stork gave a nice explanation above. What is it about the Directive command that does not force me to write PlotStyle->Directive[{Thick,Blue}]? – David Jan 31 '15 at 20:19
• @David, the docs (Directive >> Details) says: Directive[{Subscript[g, 1],Subscript[g, 2],\[Ellipsis]}] is equivalent to Directive[Subscript[g, 1],Subscript[g, 2],\[Ellipsis]]. – kglr Jan 31 '15 at 21:19

Here is a very simple way.

Plot[tbl, {t, -2, 2}, ColorFunction -> (Blue &)] • A very helpful answer. – David Jan 31 '15 at 4:58

My solution:

 sol = DSolve[y'[t] == -2/t*y[t] + 4 t, y[t], t];
resTable =
Flatten[y[t] /. Table[sol /. {C -> C}, {C, -1, 1, 0.25}]];

Show[
Plot[#, {t, -2, 2}, PlotStyle -> {Thick, Blue}] & /@ resTable,
PlotRange -> {{-2, 2}, {-5, 10}}] ### Update

Plot[#, {t, -2, 2}] & /@ resTable From this graphic, I can know the range of y axis is appoximately $[-30,20]$

Show[
Plot[#, {t, -2, 2}] & /@ resTable, PlotRange -> {{-2, 2}, {-30, 20}}] • Note how not all solutions make it up to 10 units even though PlotRange specifies the y-range to be [-5,10]. How come? – David Jan 31 '15 at 5:01
• @David, See update:) – xyz Jan 31 '15 at 5:41

I'd use Directive but here's another alternative :)

Plot[# &@tbl, {t, -2, 2}, PlotStyle -> {Thick, Blue}]


inspirated by the answer of Mr.Wizard (working till V9):

Plot draws list of curves in same color when not using Evaluate

• +1 for the mention, and that answer is now amended. – Mr.Wizard Jan 31 '15 at 7:37