How to draw a box plot like this:
make the staples, the mark of data within 1.5 IQR of the lower/upper quartile, looks like a square bracket.
I tried:
bx = sapply(5:1, function(x) rnorm(100, x, sqrt(x)))
boxplot(bx, col = "gray", pch = "", boxwex = 0.3,
medlwd = rep(3, 4), medcol = rep("white", 4),
outlty = 1, outwex = 1,
whisklty = 1,
staplelty = 1, staplewex = 1,
names = paste0("mu = ", 5:1))
title(main = "n = 100")
I do not believe it is possible to do this with staplelty
. However, you can just draw the staple as a horizontal line and add the vertical ticks.
boxplot(iris[,1:4], outlty=1, pch="")
for(i in 1:4) {
segments(c(i-0.2,i+0.2), BP$stats[5,i], c(i-0.2,i+0.2), BP$stats[5,i] - 0.1)
segments(c(i-0.2,i+0.2), BP$stats[1,i], c(i-0.2,i+0.2), BP$stats[1,i] + 0.1)
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.