I'm looking for a solution to restrict tick labels to be within the axis limits (see figure, without enlarging limits).
The idea was to apply a custom tick label style for example to the first tick:
\documentclass{report}
\usepackage{pgf}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{document}
\begin{tikzpicture}
\begin{axis}[%
scale only axis,
xmin=-1000,
xmax=1000,
ymin=0,
ymax=5,
xtick={-1000,-500,...,1000},
x tick label style={xshift={\pgfmathparse{\ticknum == 0 ? "10pt" : "0pt"}\pgfmathresult}},
]
\draw (-300,0.5)--(1000,1);
\end{axis}
\end{tikzpicture}
\end{document}
Unfortnunately this gives an "! Undefined control sequence." Applying a similar code to the label text itself works well. The use of extra ticks is not favored ( pgfplots: How to specify custom tick and label at specified value on an axis ) since the fist and last tick must have different styles. So the question is, how to customize tick label styles for individual tick labels depending on their value or position?
Thanks for any help