I have a question in respect of the BoxWhiskerChart.

The default functionality of BoxWhiskerChart is that you mouse over it and it shows you the tooltips - Max, Quartile III, Median, Quartile I and Min.

Is there a way to extract these data below the chart in a table? Obviously, I think, I could construct my own Grid to do that, but I was wondering whether I could somehow pull the data out of the BoxWhiskerChart since it is included within it anyway.

Or, at least, how to show the value for the "Upper Quartile" and "Lower Quartile" with the help of Labeling function?


2 Answers 2

data = RandomVariate[NormalDistribution[], {2, 30}];

bwc = BoxWhiskerChart[data];

You can extract the tooltip labels from bwc using Cases:

tooltips = Cases[bwc, Tooltip[a_, t_] :> t, All]

enter image description here

and use them with Labeled as a label for the chart:

Labeled[bwc, Row[tooltips , Spacer[10]], Bottom]

enter image description here

Alternatively, re-do the chart showing tooltips as ticks using the option ChartLabels:

BoxWhiskerChart[data, ChartLabels -> Placed[tooltips[[All, 1]], Axis]]

enter image description here

  • $\begingroup$ Brilliant, thank you! $\endgroup$
    – Jiri
    Mar 7, 2021 at 10:38
  • $\begingroup$ What do variables "a_" and "t_" relate to in the Tooltip[a_,t_], just for my understanding? $\endgroup$
    – Jiri
    Mar 7, 2021 at 12:07
  • $\begingroup$ @Jiri, Tooltip[expr, label] "displays label as a tooltip while the mouse pointer is in the area where expr is displayed. ". In the rule Tooltip[a_, t_] :> t, a_ is a placeholder for the first argument and t_ is a placeholder for the second argument of an expression of the form Tooltip[...,...], and the rule says, for expressions of that form take the second argument (t). Re patterns like a_, t_ see tutorial/ Introduction to Patterns $\endgroup$
    – kglr
    Mar 7, 2021 at 12:22
  • $\begingroup$ @kgir, again, thank you very much, will read the tutorial! $\endgroup$
    – Jiri
    Mar 7, 2021 at 12:55

You can obtain the quartile values using the Quantile function - linear interpolation (hydrologist method). See the Details section on the Quantile page.

enter image description here

data = Table[RandomVariate[NormalDistribution[\[Mu], 1], 100],
   {\[Mu], {0, 3, 2, 5}}];
Quantile[data[[1]], {1/4, 3/4}, {{1/2, 0}, {0, 1}}]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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