7

I saw Why is tikz so much slower when plotting a huge amount of data than WYSIWYG plotting tools? that pgfplots can be configured to do the plotting only once. How to do this? I have a document with many graphs and repeated runs takes so much time.

suresh
  • 1,447
  • 1
    See Section 32 Externalization Library of the tikz/pgf manual. Basically \usetikzlibrary{external} \tikzexternalize should be all you need. – Peter Grill Apr 03 '12 at 23:56
  • Thanks for the reply. It does work. But I have a small problem. Every time I run pdflatex, it stops in between saying that the system call 'pdflatex -shell-escape -halt-on-error -interaction=batchmode -jobname "pami2012-figure2" "\def\tikzexternalrealjob{pami2012}\input{pami2012}"' did NOT result in a usable output file 'pami2012-figure2' (expected one of .pdf:.jpg:.jpeg:.png:). Please verify that you have enabled system calls. Actually I have enabled write18 and the pdf of each of the figures are produced also. I manage by pressing 's', but how to avoid that? – suresh Apr 04 '12 at 00:20
  • 1
    It would be helpful if you would compose a fully compilable MWE that illustrates the problem including the \documentclass and the appropriate packages. This will also serve as a test case and ensure that the solution actually works for you. In the mean time, perhaps try adding -enable-write18 and ensure that you do not have older .aux files lying around. – Peter Grill Apr 04 '12 at 00:24
  • It is fine now. There was another error (file missing) which caused this behavior I guess. But that error did not show up instead the previous one (the one I posted earlier) showed up. Thanks again. It is difficult to imagine when one quickly thumbs through the pgf manual that it is the externalization library that is needed. – suresh Apr 04 '12 at 00:28

1 Answers1

5

The details of this are described in Section 32 Externalization Library of the tikz/pgf manual.

Basically adding the following to your preamble should be all that is needed:

\usetikzlibrary{external} 
\tikzexternalize
Peter Grill
  • 223,288
  • How the tex/pgfplots will identify if I modify the plots environment? Should I manually delete the pdf file created in the earlier runs? – suresh Apr 04 '12 at 00:34
  • That is one reason why it is better to keep the figures in external files and include them in your main document. Deleting the externally generated figures will should work. You could also try \tikzset{external/force remake}, which is not something I have used. – Peter Grill Apr 04 '12 at 00:44
  • I deleted the pdf files tex created and it did work. What do you mean by "keep the figures in external files"? Another latex file with tikzpicture environment and include that? But then how will that help this situation? – suresh Apr 04 '12 at 00:53
  • I meant use something like the standalone package so that they are fully compilable by themselves. That way when the file containing the figure changes, the external figure needs to be generated. If this is not automatically working with the externalization library it is easy to automate via make or latexmk. – Peter Grill Apr 04 '12 at 00:57
  • You know I was using gnuplot earlier and recently migrated to tikz and I was finding it nice. But how to do such a thing without using another graphing program? I mean by using tikz or its related packages alone? – suresh Apr 04 '12 at 01:01
  • I am not sure what you mean. It seems like that desrves a separate question. – Peter Grill Apr 04 '12 at 01:03
  • Oh standalone is a latex package. I guess I understood what you meant. I searched for standalone in pgf manual and couldnot understand that. Thanks – suresh Apr 04 '12 at 01:10
  • 2
    There are many references to the standalone pacakge on this site. For instance see How can I generate just pgf/TikZ images, not placed a whole page or slide? – Peter Grill Apr 04 '12 at 01:14
  • 1
    You can use \tikzset{external/force remake} to remake all following tikzpictures, or \tikzset{external/remake next} to only remake the next tikzpicture. – Jake Apr 04 '12 at 06:53