Search code examples
rshapesboxplotappearancelinestyle

R boxplot: How to customize the appearance of the box-and-whisker plots (e.g., remove lines or borders, change symbol of outliers)


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.


Solution

  • 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...