代码之家  ›  专栏  ›  技术社区  ›  tjebo

宽度参数和stat='identity'在geom\u箱线图中

  •  0
  • tjebo  · 技术社区  · 7 年前

    我的问题基本上是重复的 Width of boxplot created from summary stats 因为标签不完整(没有 r 也不是 ggplot2

    of this question ,我得到了

    警告:忽略未知参数:宽度

    width stat = identity

    在以前的很多线程中,这个参数似乎都起了作用(例如: Fine tuning ggplot2's geom boxplot ). 这与升级到ggplot2 3.0有关吗?

    值得注意的
    我真的不知道 希望 为了对方框图使用预先计算的值,我在开始回答上述问题时遇到了这个问题。


    sessionInfo()
    R version 3.5.0 (2018-04-23)
    Platform: x86_64-apple-darwin15.6.0 (64-bit)
    Running under: macOS High Sierra 10.13.6
    
    attached base packages:
    [1] stats     graphics  grDevices utils     datasets  methods   base     
    
    other attached packages:
    [1] ggplot2_3.0.0
    
    loaded via a namespace (and not attached):
     [1] Rcpp_0.12.17     digest_0.6.15    withr_2.1.2      dplyr_0.7.6     
     [5] assertthat_0.2.0 grid_3.5.0       plyr_1.8.4       R6_2.2.2        
     [9] gtable_0.2.0     magrittr_1.5     scales_0.5.0     pillar_1.2.3    
    [13] rlang_0.2.2      lazyeval_0.2.1   bindrcpp_0.2.2   labeling_0.3    
    [17] tools_3.5.0      glue_1.2.0       purrr_0.2.5      munsell_0.5.0   
    [21] yaml_2.1.19      compiler_3.5.0   pkgconfig_2.0.1  colorspace_1.3-2
    [25] tidyselect_0.2.4 bindr_0.1.1      tibble_1.4.2  
    
    1 回复  |  直到 7 年前
        1
  •  2
  •   Maurits Evers    7 年前

    我可以证实这种(奇怪的?)行为。

    ggplot(DF) +
        geom_boxplot(
            aes(x = x, ymin = min, lower = low, middle = mid, upper = top, ymax = max, width = 0.1),
            stat = "identity", fill = "cornflowerblue")
    

    我们收到警告

    但它确实改变了宽度

    enter image description here

    如果你移动 width = 0.1 外部 aes 你会得到一个警告,宽度会变大 改变。

    相关帖子的评论 ggplot - width of boxplot from summary stats [duplicate]


    样本数据

    DF <- data.frame(
        x = c("2012","2016"),
        min = c(29.9,37.0),
        low = c(64.0,58.0),
        mid = c(108.0,73.0),
        top = c(168.0,108.0),
        max = c(258.0,199.0))