# Show[List of plot] how to color them differently?

I have a list of plot generated in loop using

z = List[];
For[i = 0, i < 10, i++,
(
a = Plot[(x + i)^2, {x, -10, 10}];
AppendTo[z, a]
)];
Show[z]


I would like to make the Show command use different color for each plot, how can I do this?

If relevant, that's not really my function generating the plot. I have a complicated procedure generating some data points which I plot using ListPlot with a joined line.

a = ListPlot[data, Joined -> True];

• Taken at face value this question is a duplicate of (17250). The work-around, PlotStyle is in my opinion "easily found in the documentation." – Mr.Wizard Jul 4 '17 at 12:10

z = List[];
For[i = 0, i < 10, i++,
(
a = Plot[(x + i)^2, {x, -10, 10}, PlotStyle -> ColorData[97, i + 1]];
AppendTo[z, a]
)];
Show[z] Alternatively

Plot[Evaluate@Table[(x + i)^2, {i, 0, 9}], {x, -10, 10},
PlotRange -> {Automatic, 106}]


and with lists

ListLinePlot[Table[{x, (x + i)^2}, {i, 0, 9}, {x, -10, 10, 0.1}],
PlotRange -> {Automatic, 106}]

• I'd +1 but left For+AppendTo holds me :P I know it is not part of the question but still. – Kuba Jul 4 '17 at 11:03
• @Kuba I often like to add in the minimum necessary to make the OP's code work, to show what was missing. Proper rewrites don't show that, as you can see by the alternate versions. – Chris Degnen Jul 4 '17 at 11:19
Show @@ Table[Plot[(x + i)^2, {x, -10, 10},
PlotStyle -> {Black, Red, Green, Blue}[[i + 1]]], {i, 0, 3}] colors = {Black, Red, Green, Blue};

Row[{
Show @@ Table[Plot[(x + i)^2, {x, -10, 10},
ImageSize -> 400,
PlotStyle -> colors[[i + 1]]],
{i, 0, 3}],
SwatchLegend[colors, "i = " <> ToString@# & /@ Range[0, 3]]
}] You can also employ ListLinePlot

ListLinePlot[Table[{x, (x + i)^2}, {i, 0, 10, 2}, {x, -10, 10, 1}],
PlotRange -> {Automatic, {Automatic, 10^2}},
PlotMarkers -> Automatic,
PlotLegends -> Range[0, 10, 2]] fs = Array[Function[x, (x + #)^2] &, 10, 0]
Plot[Evaluate[#[x] & /@ fs], {x, -10, 10}, PlotRange -> {Automatic, 106}]


If the graphics a generated somewhere where you cannot get access to, then you can try to guess the color to replace and do this:

colorguess = ColorData;
Show[MapIndexed[{v, k} \[Function] (v /. colorguess -> ColorData[k[]]), z]] And as kuba mentioned, it is far better to generate your data z with the Table command. For and AppendTo are nasty things to use...