Mathematica Asked on August 8, 2021
DistributionChart automatically puts a Tooltip on the elements of the chart, which shows the Min, 25%, Median, 75% and Max of the data. I would like to add the count of how many elements are in the set, to this.
Some data:
data = Table[RandomVariate[NormalDistribution[], n], {n, {10, 100, 1000}}];
DistributionChart[data]
Is there a way to do this?
You can post-process the output of DistributionChart
to modify the content of tooltips:
Module[{i = 1}, DistributionChart[data] /.
Grid[x_, o__] :> Grid[Prepend[x, {Style["count", Bold], Length[data[[i++]]]}], o]]
Alternatively, you can wrap each data set with Tooltip
using the second argument to specify tooltip content:
ClearAll[toolTip]
toolTip = Tooltip[#, Grid[Transpose[{Style[#, Bold] & /@
{"count", "max", "75%", "median", "25%", "min"},
{Item[Length@#, Alignment -> Center], ##&@@Reverse @ Quantile[#, {0, 1/4, 1/2, 3/4, 1}]}}],
Dividers -> GrayLevel[.3], Alignment -> {{Center, ".", {Left}}},
Frame -> Black, BaseStyle -> AbsoluteThickness[1]]] &;
DistributionChart[toolTip /@ data]
Correct answer by kglr on August 8, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP