gpt4 book ai didi

r - R 中带有边缘箱线图的直方图

转载 作者:行者123 更新时间:2023-12-03 04:29:04 25 4
gpt4 key购买 nike

如何使直方图中的 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)

最佳答案

一种解决方案是将 boxplot() 中的 ylim= 设置为与 hist() 中的 xlim= 相同的范围.

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

enter image description here

关于r - R 中带有边缘箱线图的直方图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16083275/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com