# pgfplots - box plots min and max x-values

Im using the following code from pgfplots to create box plots:

 \begin{tikzpicture}
\begin{axis}
[
ytick={1},
yticklabels={},
y=0.7cm
]
table[row sep=\\, y index = 0] {
data\\
2\\ 2\\ 3\\ 3\\ 4\\ 4\\ 4\\ 4 \\
};
\end{axis}
\end{tikzpicture}


This produced a box plot like first one in the following picture:

In the first box plot it appears as if my data was on a scale from 2 to 4, since all of my results are in that range. The actual range for the data was from 0 to 6. Therefore i would like to show that in the box plot. This is shown in the second box plot in the picture.

How can i do this?

-

Add the xmin and xmax values:

\documentclass[png,tikz,border=10pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.8}% version
\usetikzlibrary{pgfplots.statistics}

\begin{document}
\begin{tikzpicture}
\begin{axis}
[
ytick={1},
yticklabels={},
y=0.7cm,
xmin=0,
xmax=6,
]
table[row sep=\\, y index = 0] {
data\\
2\\ 2\\ 3\\ 3\\ 4\\ 4\\ 4\\ 4 \\
};
\end{axis}
\end{tikzpicture}
\end{document}


The result:

In order to still display the x ticks 2.5 and 3.5, one might exploit the extra x ticks key:

\documentclass[png,tikz,border=10pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.8}% version
\usetikzlibrary{pgfplots.statistics}

\begin{document}
\begin{tikzpicture}
\begin{axis}
[
ytick={1},
yticklabels={},
extra x ticks={2.5,3.5},
y=0.7cm,
xmin=0,
xmax=6,
]
table[row sep=\\, y index = 0] {
data\\
2\\ 2\\ 3\\ 3\\ 4\\ 4\\ 4\\ 4 \\
};
\end{axis}
\end{tikzpicture}
\end{document}


The result:

but IMHO it is better to keep the previous version or to switch completely to a finer scale, i.e 0.5.

-