1
$\begingroup$

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)?

$\endgroup$
0

3 Answers 3

2
$\begingroup$
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.

$\endgroup$
2
  • 1
    $\begingroup$ doh, you type faster. $\endgroup$ Commented Jul 1, 2014 at 12:17
  • $\begingroup$ @bobthechemist Well.., I also looked for duplicates.. :) $\endgroup$
    – Öskå
    Commented Jul 1, 2014 at 12:18
2
$\begingroup$

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.

$\endgroup$
2
$\begingroup$

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

$\endgroup$

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