2
$\begingroup$

I like tight layouts with no unnecessary spacing. How can I do that with BoxWhiskerChart?

The BarSpacing option controls spacings between boxes, but it does not change horizontal spacings between boxes and outer frames.

data1 = RandomVariate[NormalDistribution[55, 10], 1000];
data2 = RandomVariate[NormalDistribution[65, 10], 1000];
BoxWhiskerChart[{{data1, data2}},BarSpacing -> Tiny]

enter image description here

Is there any easy option to achieve a tight layout in BoxWhiskerChart with less spacing?

$\endgroup$

2 Answers 2

3
$\begingroup$

With:

data1 = RandomVariate[NormalDistribution[55, 10], 1000];
data2 = RandomVariate[NormalDistribution[65, 10], 1000];
bw1 = BoxWhiskerChart[{{data1, data2}}, BarSpacing -> Large]

Check:

AbsoluteOptions[bw1, PlotRange]

{PlotRange -> {{0.25, 2.75}, {15.6546, 100.943}}}

and try this:

BoxWhiskerChart[{{data1, data2}}
 , BarSpacing -> Tiny
 , PlotRange -> {{0.5, 2.5}, {15, 100}}
 , ImageSize -> Medium
 ]
$\endgroup$
4
$\begingroup$
SeedRandom[1];
data1 = RandomVariate[NormalDistribution[55, 10], 1000];
data2 = RandomVariate[NormalDistribution[65, 10], 1000];

data = {{data1, data2}};

You can also use the option PlotRangePadding as follows:

BoxWhiskerChart[data, 
 BarSpacing -> .05, 
 PlotRangePadding -> -1/Length[First @ data]]

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.