2

I would like to use the following code to create a plot with a horizontal gridline and axis arrows which overshoots this gridline (like here).

However due to the line \tikzexternalize[shell escape=-enable-write18] the result is an axis without arrows. Removing this line and it works fine. I need this externalize function to buffer my graphics to speed up processing.

Any idea how to keep this functionality but also have these overshooting axis arrows?

\documentclass[10pt]{amsart}
\usepackage{tikz}
\usetikzlibrary{calc,angles,positioning,intersections,quotes,decorations.markings}
\usepackage{pgfplots}
\pgfplotsset{compat=1.11}

\usetikzlibrary{external}
\tikzexternalize[shell escape=-enable-write18]

\begin{document}
\begin{tikzpicture}
\begin{axis}[grid=both,
          xmax=18,ymax=17,
          axis x line=bottom,
                    axis y line=left,
          axis line style={shorten >=-0.5cm,-latex}
                    ]
\end{axis}
\end{tikzpicture}

\end{document}
user2653422
  • 2,333

1 Answers1

3

This is a weakness of TikZ: it excludes the bounding box of arrow tips from the picture's bounding box.

A workaround is to increase the bounding box of the picture artificially, perhaps by increasing it by some manually chosen picture position:

\documentclass[10pt]{amsart}
\usepackage{pgfplots}
\pgfplotsset{compat=1.11}

\usetikzlibrary{external}
\tikzexternalize

\begin{document}
\begin{tikzpicture}
\begin{axis}[grid=both,
          xmax=18,ymax=17,
          axis x line=bottom,
                    axis y line=left,
          axis line style={shorten >=-0.5cm,-latex}
                    ]
\end{axis}

\draw (current axis.outer north east) ++ (9pt,9pt);

\end{tikzpicture}

\end{document}

This takes the anchor current axis.outer north east and adds 9pt in x and y to it. This appears to be sufficient (I determined it with trial and error).

The external graphics now looks as follows:

enter image description here