2

According to Section 5.12.1 of the manual of PGFPlots; Revision 1.13 (2016/01/06), boxplot visualizes (see Page 472):

Median is the 0.5–quantile of the input data.
Lower quartile is the 0.25–quantile of the input data.
Upper quartile is the 0.75–quartile of the input data.
Lower whisker is the smallest data value which is larger than lower quartile−1.5 · IQR where IQR is the “inter–quartile–range”, i.e. the difference between upper quartile and lower quartile.
Upper whisker is the largest data value which is smaller than upper quartile+1.5 · IQR.

However, I would like to show the minimum, 25th, 50th, 75th, and 99th percentages of the input data. The data larger than the 99th quantile are considered outliers.

Is it possible to user-define the percentages (say, 99%) for lower/upper whisper in boxplot of PGFPlots?

Note: This can be done in Mathematica; see the post.


\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{width=7cm, compat=1.12}
\usepgfplotslibrary{statistics}

\begin{document}
\begin{tikzpicture}
  \begin{axis}[y=1cm]
    \addplot+[boxplot]
      table[row sep=\\,y index=0] {
      data\\
      1\\ 2\\ 
      11\\ 12\\ 13\\ 14\\ 15\\ 
      16\\ 17\\ 18\\ 19\\ 20\\ 
      30\\ 35\\
    };
  \end{axis}
\end{tikzpicture}
\end{document}
4
+50

To my knowledge you can change the whisker calculation only by using

/pgfplots/boxplot/whisker range={⟨number⟩} %(initially 1.5)

You find the documentation on page 477 of the manual linked in your question. However, ⟨number⟩ is not a percentage. Whiskers are calculated using the upper/lower quartile +/- ⟨number⟩ times the inter-quartile-range with

inter–quartile–range := upper quartile − lower quartile.

Hence the answer to your question is "no, the above is all you can do (as long as you do not want define the whisker values manually)".

  • If I define the whisker values manually, is there a way of calculating them (such as the min/max, the median) in pgfplots? – hengxin Apr 9 '16 at 8:46
  • Do you mean calculating like: 1) parse the input data, 2) do the math on the data, and 3) print the values? I guess there is nothing out of the box. However, there always is a way (which I don't know). But it might be utterly complicated (or more complicated than 100 ctrl+c / ctrv+v 's to paste the data manually). – thorsten Apr 11 '16 at 9:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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