I would like to save a series of graphics of a function as pictures. But the problem is that I can't manipulate the name of the graphs, because of that only the last graphics in the series is saved.

How could the whole series of graphics be saved?


gr[B_, i_] := B*2*i^2

For[i = 1, i < 5, i++,
 GE[i_] := Table[{B, gr[B, i]}, {B, 0, 9, 1}];
  ListPlot[Table[{GE[i][[l, 1]], GE[i][[l, 2]]}, {l, 1, 10}], 
   PlotRange -> All]]]

2 Answers 2


You could use Use StringJoin (<>) and ToString to give each plot a separate filename based on i


Edit: building off Nasser's answer, it probably is just easier to put everything on one plot:

GE[i_] := Table[{B, gr[B, i]}, {B, 0, 9}];
p= ListPlot[ Table[GE[i], {i, 5}], PlotLegends -> Automatic]

enter image description here


I would not do things like this, but this makes your code at least work. More functional style can be done on this. ps. also avoid For. I assume you want all plots in one pdf file.

Export["p.pdf",ListPlot[ p]]

enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.