R、ggplot 中的多个相对频率直方图

发布于 2025-01-12 12:50:07 字数 36 浏览 1 评论 0原文

我正在尝试在 R.ggplot 中绘制相对频率的多个直方图

I'm trying to plot multiple histograms of relative frequencies in R. ggplot

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

微凉 2025-01-19 12:50:07

以下是内置 iris 数据集的一些基本示例。相对部分是通过将密度乘以 binwidth 获得的。

library(ggplot2)

ggplot(iris, aes(Sepal.Length, fill = Species)) +
  geom_histogram(aes(y = after_stat(density * width)),
                 position = "identity", alpha = 0.5)
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

ggplot(iris, aes(Sepal.Length)) +
  geom_histogram(aes(y = after_stat(density * width))) +
  facet_wrap(~ Species)
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

reprex 包于 2022 年 3 月 7 日创建(v2.0.1)

Below are some basic example with the build-in iris dataset. The relative part is obtained by multiplying the density with the binwidth.

library(ggplot2)

ggplot(iris, aes(Sepal.Length, fill = Species)) +
  geom_histogram(aes(y = after_stat(density * width)),
                 position = "identity", alpha = 0.5)
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

ggplot(iris, aes(Sepal.Length)) +
  geom_histogram(aes(y = after_stat(density * width))) +
  facet_wrap(~ Species)
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

Created on 2022-03-07 by the reprex package (v2.0.1)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文