I am writing a report containing multiple plots of spectroscopic data by way of PGFplots which is fetching data from external files. It used to do the work, and after a few minutes of compilation it would render a pdf, but as I added more results to be plotted it slowed down and now it does not appear to ever finish. (I have waited for about an hour now)

The code I use is pretty much a repeat of this for thirteen different csv files, ranging between two columns and ten.

\begin{axis}[xlabel near ticks,axis background/.style={
   ymin=0,enlargelimits=false,ylabel=Counts,no marks,grid,cycle list name=color list]
  \addplot table[x index=1,y index=2,col sep=space,row sep=crcr] {spectroscopy_data.csv};
  \addplot table[x index=1,y index=3,col sep=space,row sep=crcr] {spectroscopy_data.csv};
  • does it compile if you comment out the first plots and only compile the last few?
    – long tom
    Apr 9, 2013 at 18:02
  • 1
    my typical experience is that it is extremely much faster (if you have many columns) to have every dataplot in a two column setup (yes, more files). This should give you some speedup. Or else you could read in the full data set (see the pgfplotstable manual for this) and this should yield a very nice speedup as well.
    – nickpapior
    Apr 9, 2013 at 18:04
  • long tom: Yes. It does. I got it working by enabling tikz external as suggested by ExP. Even with the external library enabled running a first time compile on my ultrabook is a borderline hopeless task unless first compiled on my stationary i7. Thankfully the problem is solved now! zeroth: That does seem to help! Thank you very much :)
    – The V
    Apr 11, 2013 at 6:45

1 Answer 1


For plots of large data-files, I recommend the TikZ-library external. It allows to compile your plots separately from your main document. This way, your main document will be typeset within seconds, while you can compile the plots one by one (if desired even in parallel).

  • 1
    Welcome to TeX.sx! Apr 9, 2013 at 18:42
  • Thanks! That does appear to solve the problem. It should be added that I had no success with it until I enabled --shell-escape. Or, on Windows -enable-write18
    – The V
    Apr 11, 2013 at 6:42
  • Depending on the data, another thing to consider is to only select every x-th datapoint (either directly with pgfplots tex.stackexchange.com/questions/68577/… or in pre-processing). Jul 1, 2018 at 8:50
  • Addition: Compilation with pdflatex needs the option -shell-escape enabled for external processing of plots.
    – azimut
    Nov 27, 2022 at 13:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .