我编写此代码,但我无法修复盒子部分的宽度,最近标签会垂直显示!但昨天工作正常!!!
dt=rnorm(100)
l=c("min:","1st Qu:","median:","3rd Qu:","max:")
bxp <- boxplot(dt, axes=TRUE,col = '#fb9a99')
v=round(bxp$stats,2)
mtext(paste(l,v),side = 4, at=bxp$stats[c(1,2,3,4,5)], line=-5.5)
答案 0 :(得分:0)
为了重现性,使用set.seed()函数。
# set seed
set.seed(1980)
# your data and text
dt <- rnorm(100)
l <- c("min:", "1st Qu:", "median:", "3rd Qu:", "max:")
# your boxplot
# with boxwex parameter you control the width of the boxes
bxp <- boxplot(dt,
axes = TRUE,
col = '#fb9a99',
boxwex = 0.5)
v <- round(bxp$stats, 2)
# your text
# with las parameter you control orientation of the text
mtext(paste(l, v),
side = 4,
at = bxp$stats[c(1, 2, 3, 4, 5)],
line = -10.5,
las = 1)