【问题标题】:How to create a grouped cumulative frequency graph with ggplot2如何使用 ggplot2 创建分组累积频率图
【发布时间】:2020-08-23 21:32:53
【问题描述】:

我正在处理元素浓度数据集,我想比较两个地方元素浓度的累积频率图,就像我在 this image,但使用 ggplot。这是一个虚拟数据集

df<-data.frame("Zone"=c(rep("A",10),rep("B",9)),"Con"=c(rnorm(10,5,2),rnorm(9,7,2.5)))

我已经设法以这种笨拙的方式为两个区域制作了一个累积频率图:

ggplot(df,aes(x=cumsum(rep(1,19)),y=sort(Con)))+geom_point()

但我不知道如何分别为两个区域制作它。 提前致谢。

【问题讨论】:

    标签: r ggplot2 cumulative-frequency


    【解决方案1】:

    我想你想使用来自 ggplot2 的stat_ecdf

    ggplot(df, aes(Con, color = Zone)) + stat_ecdf(geom = "point")
    

    【讨论】:

      猜你喜欢
      • 2021-05-04
      • 2013-03-28
      • 1970-01-01
      • 2012-10-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多