Today, I was wondering how to customize the appearance of the box-and-whisker plots. E.g., I wanted to remove the line around the box. However, the problem is, that the border argument changes the color of all lines of the box-and-whisker plots simultaneously. So, if one has the great idea to set border = "white" then the whiskers are also going to “disappear” and you have a white line representing your median.
As I could not find a solution on the internet dealing with exactly my problem, I fiddled around a little and figured some mighty settings which seem to be nearly undocumented as a whole. These settings allow you to customize the appearance of your box-and-whisker plots to a large extend. I know, some of the features have already been unveiled on stackoverflow (e.g. here). However, I could not find a complete documentation. Thus, this post.
In order to customize the appearance of the box-and-whisker plots, you have to change the med[…], box[…], whisk[…], or staple[…] argument for adjusting the line settings, or the out[…] argument for outliers.

[…] needs to be replaced by one of the following line or point arguments:
Arguments for the appearance of line elements (for more information see ?par in R):
lty: line style (e.g.,= 0 to remove the line,= 1 for solid line)lwd: line width col: line colorArguments for the appearance of outliers (for more information see ?points in R):
pch: symbol stylelwd: line widthcex: size of symbolcol: colorbg: background colorSo, here is an example of how the above boxplot might be "customized":
boxplot( … , medcol = "red", boxlty = 0, whisklty = 1, staplelwd = 4, outpch = 8, outcex = 3)
This leads to the following boxplot:

For complete documentation you should look at ?bxp (linked from the ... description in ?boxplot, and in the "See Also" in ?boxplot, and in the pars description in ?boxplot.). It documents that outpch can change the shape of the outliers (though pch works fine too). It also has boxlty, boxlwd, boxcol and boxfill for the box, and many others for the whiskers, the staples, median line...
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