Update 3: From the function Charting`iBoxWhiskerChart
we get the full list of built-in settings for Joined
:
Grid[{{Automatic | All | True |
"Median", {{Mean[#1[[1]]], Quantile[#2, 0.5`]} &}},
{"Mean", {{Mean[#1[[1]]], Mean[#2]} &}},
{"Max", {{Mean[#1[[1]]], Max[#2]} &}},
{"Min", {{Mean[#1[[1]]], Min[#2]} &}},
{"LowerQuartile", {{Mean[#1[[1]]], Quantile[#2, 0.25`]} &}},
{"UpperQuartile", {{Mean[#1[[1]]], Quantile[#2, 0.75`]} &}},
{None | False, {}}}, Dividers -> All] //
Style[#, 20, ShowStringCharacters -> True] &
Update 2: It also turns out that, in both BoxWhiskerChart
and DistributionChart
, the option Joined
has a few built-in settings such as "Mean","Min", "Max", "Median"
(in addition to arbitrary pure functions shown in the original answer.)
SeedRandom[1]
data = RandomVariate[LogNormalDistribution[1, .5], {10, 100}];
Row[BoxWhiskerChart[data, Joined -> #,
PlotLabel -> Style[Row[{"Joined -> ", "\"", #, "\""}], 16, "Panel"],
ChartStyle -> "Pastel", ImageSize -> 250] /. l : Line[__] :> {#2, Thick, l} & @@@
Transpose[{{"Min", "Mean", "Median", "Max"}, {Red, Green, Blue, Orange}}]]
It seems that only a single line can be produced using Joined
. To get multiple lines, we can Show
multiple charts with different Joined
settings:
colors = {Red, Green, Blue, Orange};
i = 1;
Show[BoxWhiskerChart[data, Joined -> #,
ChartBaseStyle -> {EdgeForm[Opacity[.1]], FaceForm[]},
ChartStyle -> "Pastel"] & /@ {"Min", "Max", "Mean", "Median"}] /.
l_Line :> {colors[[i++]], Thick, l}
Using DistributionChart
in place of BoxWhiskerChart
above we get
and
Update: A pure function setting for Joined
also works for BarChart
. Such functions apply to the list of horizontal and vertical ranges {{xmin, xmax}, {ymin, ymax}}
of the rectangles:
BarChart[{{3, 3, 4, 1}, 2 + {3, 3, 4, 1}}, Joined -> (Mean /@ # & )] /.
l : Line[x_ /; (x[[1, 2]] =!= 0.)] :> {Red, Thick, l}
BarChart[{{3, 3, 4, 1}, 2 + {3, 3, 4, 1}}, Joined -> (Max /@ # & )] /.
l : Line[x_ /; (x[[1, 2]] =!= 0.)] :> {Red, Thick, l}
Original Answer:
BoxWhiskerChart with the option Joined
It turns out that, in BoxWhiskerChart
, functions can be used as the setting for the option Joined
and the setting (Mean[#2] &)
gives the desired result without having to use ListLinePlot
:
BoxWhiskerChart[{a, b, c}, "Mean", Joined -> (Mean[#2] &), ChartStyle -> "Pastel"]
If desired, post-process to style the line
BoxWhiskerChart[{a, b, c}, "Mean", Joined -> (Mean[#2] &), ChartStyle -> "Pastel"] /.
l : Line[__] :> {Red, Thick, l}
Another example:
SeedRandom[1]
data = RandomVariate[NormalDistribution[], {10, 100}];
BoxWhiskerChart[data, "Mean", Joined -> (Mean[#2] &), ChartStyle -> "Pastel"] /.
l : Line[__] :> {Red, Thick, l}
DistributionChart with the option Joined
Joined
works the same way in DistributionChart
.
DistributionChart[{a, b, c}, Joined -> (Mean[#2] &),
ChartElementFunction -> "PointDensity", ChartStyle -> "Pastel"] /.
l : Line[__] :> {Red, Thick, l}
DistributionChart[data, Joined -> (Mean[#2] &),
ChartElementFunction -> "PointDensity", ChartStyle -> "Pastel"] /.
l : Line[__] :> {Red, Thick, l}
BoxWhiskerChart[dat, {"Mean", {"MedianMarker", None}}, Prolog -> {ColorData[97, 1], Line[Transpose[{Range[3], Mean /@ dat}]]}]
? $\endgroup$