【问题标题】:What does bar means in ggplot geom="bar"? I am confused with stat="identity"ggplot geom="bar"中的bar是什么意思?我对 stat="identity" 感到困惑
【发布时间】:2013-07-10 23:05:13
【问题描述】:

我对 ggplot2 包有疑问。 使用菱形数据,我看不出下面三组代码的区别。

qplot(color, data = diamonds, geom = "bar")

qplot(color, data = diamonds, geom = "bar", weight = carat) +
scale_y_continuous("carat")

qplot(color, carat, data=diamonds, geom="bar",
      stat = "identity", position = "identity") + 
theme(legend.position = "none")

【问题讨论】:

    标签: r ggplot2


    【解决方案1】:

    第一个图显示了每种颜色的钻石数量(计数)。

    第二个按克拉计算钻石的重量。也就是说,它显示了每种颜色的总克拉数。

    最后一个图只是显示了每个颜色类别中最重的钻石。这与 stat="identity" 无关。默认位置是 position="stack"。 position="identity" 不是堆叠,而是将每颗钻石的克拉叠加在一起,您只会看到最大的一颗。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-10-23
      • 1970-01-01
      • 2022-11-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-12-10
      相关资源
      最近更新 更多