And*_*ndy 5 r histogram boxplot
如何使直方图中的X轴与边缘箱图匹配?
data <- rnorm(1000)
nf <- layout(mat = matrix(c(1,2),2,1, byrow=TRUE), height = c(1,3))
layout.show(nf)
par(mar=c(5.1, 4.1, 1.1, 2.1))
boxplot(data, horizontal=TRUE, outline=FALSE)
hist(data)
Run Code Online (Sandbox Code Playgroud)
Did*_*rts 11
一个解决办法是设置ylim=在boxplot()以相同的范围内xlim=的hist().
set.seed(123)
data <- rnorm(1000)
nf <- layout(mat = matrix(c(1,2),2,1, byrow=TRUE), height = c(1,3))
par(mar=c(5.1, 4.1, 1.1, 2.1))
boxplot(data, horizontal=TRUE, outline=FALSE,ylim=c(-4,4))
hist(data,xlim=c(-4,4))
Run Code Online (Sandbox Code Playgroud)
