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

前端 未结 2 1774
-上瘾入骨i
-上瘾入骨i 2020-12-23 09:02

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

相关标签:
2条回答
  • 2020-12-23 09:03

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

    0 讨论(0)
  • 2020-12-23 09:15

    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.

    enter image description here

    […] 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 color

    Arguments for the appearance of outliers (for more information see ?points in R):

    • pch: symbol style
    • lwd: line width
    • cex: size of symbol
    • col: color
    • bg: background color

    So, 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:

    enter image description here

    0 讨论(0)
提交回复
热议问题