Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

\documentclass{article}  
\usepackage{graphicx,tikz}                  
\usepackage{pgfplots}  
\pgfplotsset{compat=newest}  
\begin{document}  
\begin{tikzpicture}
\begin{axis}[xlabel near ticks,axis background/.style={
   fill=gray!70},width=\textwidth,height=0.4\textwidth,xticklabel=eV,
   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};
  \addlegendentry{C$_{\text{K}\alpha}$}
  \addplot table[x index=1,y index=3,col sep=space,row sep=crcr] {spectroscopy_data.csv};
  \addlegendentry{O$_{\text{K}\alpha}$}
\end{axis}
\end{tikzpicture}  
\end{document}
share|improve this question
    
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 :) –  Mr. V Apr 11 '13 at 6:45

1 Answer 1

up vote 3 down vote accepted

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

share|improve this answer
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 –  Mr. V Apr 11 '13 at 6:42

Your Answer

 
discard

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.