# One axis in pgfplots

I try to make one axis exercices for students, thus I try to customize pgflots but I don't understand what append in this examples :

\documentclass{article}
\usepackage{tikz,pgfplots}
\pgfplotsset{%
tick label style={font=\footnotesize},
label style={font=\small},
legend style={font=\small},
axis x line = center,
axis y line = center,
every axis/.style={pin distance=1ex}
%xlabel near ticks
%
}   %%%% fin pgfplotsset

\begin{document}

\begin{tikzpicture}
\begin{axis}[%
axis x line=center,
axis y line=none,
xmin=-3,xmax=3,
]
\end{axis}
\end{tikzpicture}

\begin{tikzpicture}
\begin{axis}[%
axis x line=center,
axis y line=none,ymin=0,ymax=1,
xmin=-3,xmax=3,
]
\end{axis}
\end{tikzpicture}

\begin{tikzpicture}
\begin{axis}[%
axis x line=center,
axis y line=none,
xmin=-3,xmax=3,
xticklabels={8,3,,5,,7},
]
\end{axis}
\end{tikzpicture}

\begin{tikzpicture}
\begin{axis}[%
axis x line=center,
axis y line=none,
xmin=-3,xmax=3,
xticklabels={8,3,,5,,7},
extra x ticks={.75},
]
\end{axis}
\end{tikzpicture}

\end{document}


In the first : xmin, xmax doesn't work ? In the second : with it works in the second ? In the third : where is the first 8 ? In the forth : where is extra tick ?

Once the initial 8 from xlabels appears on the place of extra label ! I use texlive with both last versions of pgf-tikz and pgfplots.

1. If you check your .log file, you will see Package pgfplots Warning: You have an axis with empty range (in direction y). Replacing it with a default range and clearing all plots. on input line 34. So because you didn't specify a range for the y direction (and you didn't give PGFPlots a chance to figure it out itself by providing a plot, for example), PGFPlots reverts to the default axis limits. Simply adding ymin=0, ymax=1, for instance, will solve this problem (which is what you did in the second axis). This should be done for all your axes.

2. See 1.

3. xticklabels when used with automatically determined tick positions sometimes swallows the first tick label. The safest bet is to set xtick={-3,...,3} to explicitly specify that there should be tick marks at every integer position between -3 and 3.

4. See 1. Note that in this case you should also provide a list of labels for the extra tick positions, otherwise PGFPlots will use the same list as for the main ticks and label the first extra tick with 8.

\documentclass{article}
\usepackage{tikz,pgfplots}
\pgfplotsset{%
tick label style={font=\footnotesize},
label style={font=\small},
legend style={font=\small},
axis x line = center,
axis y line = center,
every axis/.style={pin distance=1ex},
trim axis left
%xlabel near ticks
%
}   %%%% fin pgfplotsset

\begin{document}

\begin{tikzpicture}
\begin{axis}[%
axis x line=center,
axis y line=none,
xmin=-3,xmax=3,
]
\end{axis}
\end{tikzpicture}

\begin{tikzpicture}
\begin{axis}[%
axis x line=center,
axis y line=none,ymin=0,ymax=1,
xmin=-3,xmax=3,
]
\end{axis}
\end{tikzpicture}

\begin{tikzpicture}
\begin{axis}[%
axis x line=center,
axis y line=none,
xmin=-3,xmax=3,ymin=0, ymax=1,
xtick={-3,...,3},
xticklabels={8,3,,5,,7},
]
\end{axis}
\end{tikzpicture}

\begin{tikzpicture}
\begin{axis}[%
axis x line=center,
axis y line=none,
xmin=-3,xmax=3, ymin=0, ymax=1,
xtick={-3,...,3},
xticklabels={8,3,,5,,7},
extra x ticks={.75},
extra x tick labels={x}
]
\end{axis}
\end{tikzpicture}

\end{document}