# Pgfplots gives spurious lines in external mode with geometry

This is not a major problem but all the same I would like to confirm that I am not doing anything wrong. Geometry package with showframe=true option is used to see if all the figures are within the margins. Also, tikz external library is used and the plot shows some spurious horizontal and vertical lines.

This happens only if showframe=true is set in geometry and the tikz external library is used. If external is switched off, the plot is drawn correctly. As I said earlier, since I am not going to display frame in the final draft, this is not a major issue.

MWE

\documentclass{report}
\usepackage[showframe=true,hmargin=3cm,vmargin=2cm]{geometry}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.7}

%Comment out to not use external library and get correct figure.
\usetikzlibrary{external}
\tikzexternalize

\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}
\begin{axis}
\end{axis}
\end{tikzpicture}
\end{figure}
\end{document}

-
I think the comment of @JLDiaz should become an answer. Apparently, both packages change the TeX \shipout routine. As long as the resulting bounding box is correct... – Christian Feuersänger Jan 3 '13 at 19:34
@JLDiaz Can you convert your comment to an answer? – percusse Mar 11 '13 at 21:05
@percusse Done. – JLDiaz Mar 12 '13 at 0:33

I had the same problem and fixed it by writing the following after the \tikzexternalize command:
\tikzifexternalizing{\setkeys{Gm}{showframe=false}}{}