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.

  • $\begingroup$ Does AppendTo[{plot}, plot2] work? If the plots are large, I think you can consider Rasterize them, which I think would be faster. $\endgroup$ Jul 10, 2013 at 17:26

2 Answers 2


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.

  • $\begingroup$ this helps, thank you very much $\endgroup$
    – JoshRPD
    Jul 10, 2013 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


Your Answer

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

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