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!


closed as off-topic by MarcoB, m_goldberg, user9660, Öskå, PlatoManiac Jun 6 '16 at 20:02

This question appears to be off-topic. The users who voted to close gave these specific reasons:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – m_goldberg, PlatoManiac
  • "This question cannot be answered without additional information. Questions on problems in code must describe the specific problem and include valid code to reproduce it. Any data used for programming examples should be embedded in the question or code to generate the (fake) data must be included." – MarcoB, Community, Öskå
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    $\begingroup$ Which Version of Mathematica are you using? $\endgroup$ – gwr Jun 1 '16 at 9:41

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}}]

Mathematica graphics

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

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

Mathematica graphics

  • 1
    $\begingroup$ Nice solution, but it somehow assumes that the OP's hypothesis "PlotRangedoes not work for BoxWhiskerChart" is true when it isn't. $\endgroup$ – gwr Jun 1 '16 at 9:36
  • 1
    $\begingroup$ @gwr, just added a note on "doesn't work". $\endgroup$ – kglr Jun 1 '16 at 9:39

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