Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am creating a boxplot with pgfplots, using the builtin statistics library. I load the input data from a table file.

\usepackage{pgfplots}
\usepgfplotslibrary{statistics}
...
\begin{tikzpicture}
\begin{axis}[boxplot/draw direction=y]
   \addplot+[boxplot] table[
     col sep=tab,
     x expr=\coordindex,
     y=aColName] {aFileName};
\end{axis}
\end{tikzpicture}

Is it possible to draw the plot without outliers? Or hide them? I don't want to pre-calculate the boxplot values by hand.

share|improve this question
add comment

1 Answer

up vote 5 down vote accepted

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]
\addplot+[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}
share|improve this answer
    
Works like a charm, thanks. –  Entropia Jun 3 '13 at 12:00
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.