R中带有边际箱线图的直方图 [英] Histogram with marginal boxplot in R

查看:147
本文介绍了R中带有边际箱线图的直方图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用边际箱图使直方图中的X轴匹配?

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)


推荐答案

一种解决方案是在 boxplot() ylim = >与 hist()中的 xlim = 相同。

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, horizontal=TRUE,  outline=FALSE,ylim=c(-4,4))
hist(data,xlim=c(-4,4))

这篇关于R中带有边际箱线图的直方图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆