1

I made a table of ten plots:

Table[Plot[u[t, x] /. wws, {x, -10, 10}], {t, 0, 10, 1}]

I want to save them all to my file system. I know, that I can save each plot separataly by "Save as...", but it's tedious. Can anybody offer anything that will automate this (because in future it will be 50 plots)?

m_goldberg
  • 107,779
  • 16
  • 103
  • 257
user12297
  • 155
  • 4

3 Answers3

2
plots = Table[Plot[x, {x, -10, 10}], {t, 0, 10, 1}];
names = ToString@StringForm["~/Plot``.pdf", #] & /@ ToString /@ Range@Length@plots;
Export[#1, #2] & @@@ Thread@{names, plots}

Giving ten different plots exported in PDF.

Öskå
  • 8,587
  • 4
  • 30
  • 49
2

One way to do this is to Map and Export routine:

plots = Table[Plot[Sin[a x], {x, 0, 4 Pi}], {a, 1, 10}]
MapIndexed[Export[ToString[First@#2] <> ".png", #1] &, plots]

This stores the files with names 1.png, 2.png, etc.

bobthechemist
  • 19,693
  • 4
  • 52
  • 138
2

Just for variety and to deal with ordering issues that some times arise with 1,10,2 by padding left with zeros. This assumes that plots contains list of graphics objects:

MapThread[
 Export["plot" <> #1 <> ".pdf", #2] &, {IntegerString[#, 10, 3] & /@ 
   Range[Length@plots], plots}]

File will be "plot001.pdf","plot002.pdf",etc

ubpdqn
  • 60,617
  • 3
  • 59
  • 148