I am attempting to create a simple Cartesian plane using pgfplots, where the positive ends of the x and y-axis extend slightly past the square grid. So far, what I have is as follows:
\documentclass{article}
\usepackage{tikz, pgfplots}
\begin{document}
\begin{center}
\begin{tikzpicture}
\begin{axis}[
axis lines=middle,
axis line style=->,
xmin=-10,xmax=10,
ymin=-10,ymax=10,
grid=both,
grid style={draw=gray!25},
xtick={-10, -8, ..., 10}, xtick style={yshift=-0.5ex},
ytick={-10, -8, ..., 10}, ytick style={xshift=-0.5ex},
yticklabel style={xshift=-0.5ex},
minor tick num=1,
minor tick length=0.5ex,
minor x tick style={yshift=0.25ex}, minor y tick style={xshift=0.25ex},
]
\end{axis}
\end{tikzpicture}
\end{center}
\end{document}
For reference, here is the template I'm attempting to replicate.
By extending the xmax/ymax values, the grid lines by default extend to these values. Would anyone have any suggestions on either limiting the grid length or extending the positive axis ends?
Best Answer
Welcome! You can use
shorten
and use a negative distance.Or with x and y labels.