1
$\begingroup$

First, create two BoxWhiskerChart: box1 and box2

data = { {{1, 2, 5}, {7, 2}},  {{5, 7, 2, 2, 5}, {7, 2, 5}} }
style = Sequence[{
  {"Whiskers", Dashed},
  {"Outliers", None},
  {"MedianMarker", 1, Directive[White]}},
  ChartStyle -> 56,
  ImageSize -> Medium,
  ChartLabels -> {{"A", "B", "C"}, None}];

box1 = BoxWhiskerChart[data, style]
box2 = BoxWhiskerChart[data, style]

Then put them together using GraphicsGrid and add ChartLegends for them using Legended:

boxes = Legended[
  GraphicsGrid[{{Graphics[box1], Graphics[box2]}}],
  ChartLegends -> Placed[{"x", "y"}, "Row"] ]

However, it does not produce the legends:

boxes

How to share ChartLegends among multiple BoxWhiskerCharts in GraphicsGrid?


Related post:

I have encountered a similar problem How to share LineLegend among sub-figures in GraphicsGrid?. However, the answer there does not work here.

$\endgroup$
1

1 Answer 1

4
$\begingroup$

The code from the previous question's answer seems to work just as well here with the use of SwatchLegend:

Legended[GraphicsGrid[{{Graphics[box1], Graphics[box2]}}], 
 Placed[SwatchLegend[56, {"A", "B"}, LegendLayout -> "Row"], Above]]

enter image description here

$\endgroup$

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.