# Expanding tick marks and labels beyond data set

I am looking to expand the y- and x-axis values beyond the data for visual reasons. I tried to force the ticks and labels, but it did not work. I wish the two axis to start at zero and end beyond the maximum datapoints. This is my first attempt at pgfplots.

\documentclass{article}
\usepackage{tikz,pgfplots}
\usetikzlibrary{snakes,backgrounds,arrows,decorations.markings}
\begin{document}
%
%
\begin{center}
\begin{tikzpicture}
\begin{axis}[
small,
xlabel=Time in min.,
ylabel=Distance in mi.,
axis y line=left,
axis x line=bottom,
xtick={0,2,4,6,8,10,12},
ytick={0,1,1.5,2,...,3.5},
xticklabels={0,2,4,6,8,10,12},
yticklabels={0,1,1.5,2,...,3.5},
xtickmin=0,
xtickmax=11,
ytickmin=0,
ytickmax=3.5
]
coordinates {
(1,1)
(2,1)
(5,3)
(8,3)
(9,2)
(10,3)
};
\end{axis}
\end{tikzpicture}
\end{center}
%
%
\end{document}

-

The visible range of the plot can be specified using xmin, xmax, ymin, etc. If you want to automatically extend the axis ranges beyond the largest values, you can set enlargelimits=upper (this behaviour can be controlled quite precisely: You can enlarge the axis by a certain number of units, by a certain percentage, or by a certain length. Check the manual for details).

In your example, you can simply say xmin=0, ymin=0, enlargelimits=upper, without the need to specify the ticks yourself:

\documentclass{article}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
small,
compat=1.8,
xlabel=Time in min.,
ylabel=Distance in mi.,
axis y line=left,
axis x line=bottom,
xmin=0,
ymin=0,
enlargelimits=upper
]
coordinates {
(1,1)
(2,1)
(5,3)
(8,3)
(9,2)
(10,3)
};
\end{axis}
\end{tikzpicture}
\end{document}

-
Couldn't find that in the manual. Thanks – Calhistorian Jun 4 '13 at 18:09