How can I specify the plot range of a BoxWhiskerChart? [closed]

I am combining multiple BoxWhiskerCharts using GraphicsGrid. This works properly, however I want the different charts to have the same y-axis for enabling an easy comparison of the data sets.

How can I specify the range of a BoxWhiskerChart? PlotRange doesn’t work, and I can’t find a corresponding command for this kind of chart.

My current code is

P1 = BoxWhiskerChart[{DataA, DataB},
ChartLabels -> {Placed[{“A”, “B”}, Above]}]

P2 = BoxWhiskerChart[{DataC, DataD},
ChartLabels -> {Placed[{“C”, “D”}, Above]}]

GraphicsGrid[{{P1, P2}}]

I am thankful for any tips!

=================

=================

2 Answers
2

=================

I can’t see your problem. PlotRange in Version 10.4.1 does work fine for BoxWhiskerChart (as it should):

d1 = RandomVariate[NormalDistribution[10, 3], 100];
d2 = RandomVariate[NormalDistribution[5, 1], 100];
d3 = RandomVariate[NormalDistribution[-5, 3], 100];
d4 = RandomVariate[NormalDistribution[-10, 1], 100];

P1 = BoxWhiskerChart[ {d1, d2},
ChartLabels -> {Placed[{“A”, “B”}, Above]},
PlotRange -> {All, {-20, 30}}
];

P2 = BoxWhiskerChart[{d3, d4},
ChartLabels -> {Placed[{“C”, “D”}, Above]},
PlotRange -> {All, {-20, 30}}
];

GraphicsGrid[{{P1, P2}}, ImageSize -> Large]

{DataA, DataB, DataC, DataD} = 10 + RandomReal[NormalDistribution[], {4, 100}];
P1 = BoxWhiskerChart[{DataA, DataB}, ChartLabels -> {Placed[{“A”, “B”}, Above]}];
P2 = BoxWhiskerChart[{DataC, DataD}, ChartLabels -> {Placed[{“C”, “D”}, Above]}];

GraphicsGrid[{Show[#, PlotRange -> {0, 20}] & /@ {P1, P2}}]

Note: Re PlotRange doesn’t work, it does in Version 9.0.1:

BoxWhiskerChart[{DataA, DataB}, ChartLabels -> {Placed[{“A”, “B”}, Above]},
PlotRange -> {0, 20}]

1

 

Nice solution, but it somehow assumes that the OP’s hypothesis “PlotRangedoes not work for BoxWhiskerChart” is true when it isn’t.
– gwr
Jun 1 at 9:36

1

 

@gwr, just added a note on “doesn’t work”.
– kglr
Jun 1 at 9:39