pgfplots - draw boxplot without outliers
If you add the following code snippet to your preamble, you can use hide outliers
to locally disable plotting the outliers:
\makeatletter
\pgfplotsset{
boxplot/hide outliers/.code={
\def\pgfplotsplothandlerboxplot@outlier{}%
}
}
\makeatother
\documentclass{article}
\usepackage{pgfplots}
\usepgfplotslibrary{statistics}
\begin{document}
\makeatletter
\pgfplotsset{
boxplot/hide outliers/.code={
\def\pgfplotsplothandlerboxplot@outlier{}%
}
}
\makeatother
\begin{tikzpicture}
\begin{axis}[y=1cm, try min ticks=2]
\addplot+[boxplot]
table[row sep=\\,y index=0] {
data\\
1\\ 2\\ 1\\ 5\\ 4\\ 10\\
7\\ 10\\ 9\\ 8\\ 9\\ 9\\
21\\
};
\end{axis}
\end{tikzpicture}
\begin{tikzpicture}
\begin{axis}[y=1cm, try min ticks=2]
% somewhen the simple statement of `hide outliers` broke.
% Now the full path to the style needs to be written.
\addplot+[boxplot, /pgfplots/boxplot/hide outliers]
table[row sep=\\,y index=0] {
data\\
1\\ 2\\ 1\\ 5\\ 4\\ 10\\
7\\ 10\\ 9\\ 8\\ 9\\ 9\\
21\\
};
\end{axis}
\end{tikzpicture}
\end{document}