具有多个种群的 R 直方图 [英] R histogram with multiple populations

查看:24
本文介绍了具有多个种群的 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天全站免登陆