【问题标题】:Using qplot to make a dotplot使用 qplot 制作点图
【发布时间】:2013-10-07 18:09:02
【问题描述】:

如果x 为数字且y 为空,我想为qplot 创建一个包装器,将默认几何图形从histogram 更改为dotplot。但是我无法让qplotgeom_dotplot 一起工作:

> x <- rnorm(100)
> qplot(x, geom="dotplot")
stat_bindot: binwidth defaulted to range/30. Use 'binwidth = x' to adjust this.
Error in if (params$stackdir == "up") { : argument is of length zero

如何使用qplot 来创建此图:

ggplot(,aes(x=x)) + geom_dotplot()

【问题讨论】:

    标签: r ggplot2 cran


    【解决方案1】:

    qplot 缺少为 geom_dotplot 设置的默认美学。您可以手动指定它们:

    qplot(x, geom = "dotplot",
          stackdir = "up", stackgroups = FALSE, binaxis = "x")
    

    加上binwidth。

    【讨论】:

    • 我想这可能算作一个错误。
    【解决方案2】:

    不是真正的答案,但考虑这两种不会引发错误的尝试:

    g <- qplot(x)
    g + geom_dotplot()  # makes a weird hybrid dotplot and barplot
    

    或者:

    g <- qplot(x, stat="bindot")
    g    # was expecting dots but got bars, go figure.
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-04-21
      • 1970-01-01
      • 2015-05-22
      • 2016-03-13
      • 2020-07-16
      • 1970-01-01
      • 1970-01-01
      • 2011-02-26
      相关资源
      最近更新 更多