Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to be able to import my data and create multiple listlineplots, but my inputs for each plot are very large. I am able to assign variables to each plot and then use GraphicsGrid to view them all, but i have to copy and paste the input for each plot. I am wondering if there is a way to create the plot, store it, then create the next plot and store it along with the first, and so on. This way when i am done creating all plots I can just view them all and compare them together in a grid. I have attempted to use AppendTo, but i am unable to even store two plots, as the first plot is erased in some manner. Here is an example of how I start:

        filename = "af.txt";
    datafile = Import[filename, "CSV"];
        plot = ListLinePlot[datafile]
filename2 ="ai.txt";
datafile2 = Import[filename2,"CSV"];
plot2 = ListLinePlot[datafile2]

So I am trying to store the plot, and then my hope is to just change the input filename and continue on to save space. Any help would be appreciated.

share|improve this question
Does AppendTo[{plot}, plot2] work? If the plots are large, I think you can consider Rasterize them, which I think would be faster. – xslittlegrass Jul 10 '13 at 17:26

I guess your data files are named well, I mean according to some pattern.

However here is a n example


(*creating data file with serial name*)
Table[Export[StringJoin[ToString[n], ".dat"],
Table[{x, Sin[n x]}, {x, 0., 2 \[Pi], \[Pi]/10.}], "Table"], {n, 1, 3}]

This will create three data file {"1.dat", "2.dat", "3.dat"}. Now you can Import data from files, one by one, and put all the Plots in a table.

graph = Table[data = Import[StringJoin[ToString[n], ".dat"]]; 
ListLinePlot[data], {n, 1, 3}];
graph // TableForm

graph has all your plots. You can put all of them in a table or can call the individually.

share|improve this answer
this helps, thank you very much – JoshRPD Jul 10 '13 at 20:11

You can do a Grid for your plot and then export the grid.

let us take an example:

 Grid[{ {ListPlot[RandomReal[1, 100]],Plot[Sin[x], {x, 0, 1}]} }]

enter image description here

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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