R直方图与多个人口 [英] R histogram with multiple populations

查看:158
本文介绍了R直方图与多个人口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有兴趣在R中创建一个包含两个(或更多)群体的直方图,这意味着 - 我不希望两个直方图共享相同的图形,而是包含两个或更多颜色的条形图。

I'm interested in creating a histogram in R that will contain two (or more) population on top of each other, meaning - I don't want a two histograms sharing the same graph but a bar containing two colors or more.

发现下面的图片 - 这是我想要完成的。

Found the image below - this is what I want to accomplish.

有什么想法?

推荐答案

这实际上是ggplot2中令人讨厌的默认值:

That is actually the annoying default in ggplot2:

library(ggplot2)
ggplot(iris, aes(x=Sepal.Length, fill=Species)) +
  geom_histogram()

这篇关于R直方图与多个人口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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