How can I reduce the width of each individual boxplot in Base R?
I do not want to change the relative sizes of the boxplots, which I understand can be done with the width
argument
(this is not the same question as this post, which asks about removing whitespace)
boxplot(mpg ~ cyl,
data=mtcars)
You can set the default width using the boxwex=
parameter. More information on these parameters are actually found in the ?bxp
help page which does the boxplot drawing. There's a mention of this when describing the ...
parameter in the ?boxplot
help page.
boxplot(mpg ~ cyl, data=mtcars, boxwex=.2)
The graphic parameter you want is boxwex
, see help("bxp")
, the function that does the plotting part of the box-and-whiskers plot.
old_par <- par(mfrow = c(3, 1))
boxplot(mpg ~ cyl, data=mtcars, boxwex = 0.1)
boxplot(mpg ~ cyl, data=mtcars, boxwex = 0.4)
boxplot(mpg ~ cyl, data=mtcars, boxwex = 0.8)
par(old_par)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With