Histogram with marginal boxplot in R
问题 How make matching X-axis in histogram with marginal boxplot? 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) 回答1: One solution would be to set ylim= in boxplot() to the same range as xlim= in 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,