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 '13 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. – zeroth Apr 9 '13 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 '13 at 6:45

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! – Peter Jansson Apr 9 '13 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 '13 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). – 3244611user Jul 1 '18 at 8:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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