R中同一图形中的并排直方图? [英] Side by Side histograms in the Same Graph in R?
问题描述
这实际上应该非常简单,但是我很难找到解决该问题的方法.
This should actually be really simple but I'm having a really hard time finding a solution to this problem.
我在R中有两个非常简单的数值向量.我只是试图用它们绘制直方图.但是我希望它们在同一张图上.棘手的部分是R默认情况下会重叠这两个直方图.我希望这些垃圾箱可以并排放置,以便可以更好地可视化显示数据.
I have two very simple numeric vectors in R. I am simply trying to plot a histogram with them. However I would like them to be on the same graph. The tricky part is R overlaps these two histograms by default. I would like the bins to be simply side by side so I can get a better visual representation of the data.
基本上这就是我想做的
我一般对R语言和统计计算语言还是陌生的,因此,如果您能回答我这个令人沮丧的问题,我将不胜感激.
I am fairly new to R and statistical computing languages in general so I would appreciate it if you would answer my frustrating problem.
推荐答案
该示例来自使用plotrix
程序包.在此处找到了代码.您首先需要安装该软件包,然后才能访问multihist
函数:
The example comes from using the plotrix
package. Code was found here. You will first need to install that package before you can access the multihist
function:
#install.packages("plotrix")
require(plotrix)
l <- list(rnorm(50),rnorm(50,sd=2),rnorm(50,mean=3))
multhist(l)
这篇关于R中同一图形中的并排直方图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!