# Combining graphics twice

I have a for loop that produces a few line plots. After it is produced, it is appended together, and I'm using the "Show" command to combine the plots together. As shown in the example code below:

For[l = 1, l <= 21, l++,
a = ListLinePlot[(mylist[[l]] + l*5)];
AppendTo[z, a]];
Show[z, PlotRange -> All] // Print)]


"mylist" is time series data. Looping through it and adding multiples of 5 with the code above allows me to produce a plot as the image below:

I'd like to now combine a few plots that are produced this way in a grid. I have tried using an outer "for" loop, and the command GraphicsGrid, but that doesn't seem to work. Are there any other ways I can go about this? Thanks.

• what does mylist look like?
– kglr
Sep 20, 2019 at 15:29
• Hi @kglr, I've edited the question above to answer your question of what "mylist" looks like. Thank you. Sep 20, 2019 at 15:35
• thank you very much Jin.
– kglr
Sep 20, 2019 at 18:24

SeedRandom[1]
mylist1 = TimeSeries[#, {5}] & /@ RandomReal[{-1, 1}, {21, 50}];
mylist2 = TimeSeries[#, {20}] & /@ RandomReal[{-10, 10}, {10, 40}];


(1) You can use Table instead of a For loop to construct transformed series, and (2) you can use a single ListLinePlot for mylist1 instead of combining 21 separate plots with Show:

z1a = ListLinePlot[Table[mylist1[[l]] + l*5, {l, 1, 21}] ];
z2a = ListLinePlot[Table[mylist2[[l]] + l*50, {l, 1, 10}] ];
GraphicsGrid[{{z1a}, {z2a}}]


Alternatively, you can use MapIndexed:

z1b = ListLinePlot[MapIndexed[# + #2[[1]] 5 &, mylist1] ];
z2b = ListLinePlot[MapIndexed[# + #2[[1]] 50 &, mylist2] ];
GraphicsGrid[{{z1b}, {z2b}}]


same picture