When I do
\tikzexternalize
\tikzsetfigurename{foo}
\begin{tikzpicture}
...
\end{tikzpicture}
and compile my LaTeX file with pdflatex --shell-escape, a file foo0.pdf is created the first time and that PDFfile is just included from then on.
However, the same doesn't work for pgfpictures. I'm creating figures using matplotlib (which rocks, btw.) and they're plain PGF. When I include those, they are compiled every time, which is pretty time consuming.
I didn't find any way to include a pgfpicture in a tikzpicture. When I tried simply to do something like this:
\begin{tikzpicture}
\begin{pgfpicture}
...
\end{pgfpicture}
\end{tikzpicture}
I got "TeX capacity exceeded" errors.
tikzpictureis a special form of apgfpicture, so you can't use the one inside the other. Note that there is also thestandalonebundle which allows to compile picture environments or any other LaTeX material just once and automatically include the resulting PDF then. However, it works the other way around: the pictures are supposed to be inside a file of its own with an own preamble. – Martin Scharrer♦ Jan 27 at 12:25\tikzexternalizeworks only fortikzpictures. Externalization support forpgfpicturesis somewhat more low-level than fortikzpictures(which makes perfect sense, sincepgfitself is more low-level thantikz). I suggest you read about externalizingpgfgraphics in section 80 (Externalizing Graphics, under VII The Basic Layer) of the PGF manual. – Sašo Živanović Jan 27 at 12:57graphic1andgraphic2and I dopdflatex --jobname graphic1 mydoc.tex, I get "!pdfTeX error: pdflatex (file graphic2): unknown type of image" and vice-versa. – Johannes Bauer Jan 28 at 11:26matplotlib's PGF backend. You could try matplotlib2tikz instead, which converts to tikz. Depending on what you are doing, you might be interested in mypythontexpackage, which can also be used to cache matplotlib figures (and can create them in parallel, if your processor has multiple cores). – G. Poore Jan 29 at 1:06