宽度参数和STAT =在geom_boxplot“身份”(Width parameter and s

2019-11-05 04:18发布

我的问题是基本的副本从汇总统计创建箱线图的宽度已经只接受因为标签不完整(无差关注r也不ggplot2标签),我也相应提出了一些修改。

我试图重现例如这个问题 ,和我

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

我发现这很奇怪,因为我已经使用width之前作为参数。 拆卸时警告消失stat = identity

在很多以前的线程,这个参数似乎工作(如: 微调GGPLOT2 GEOM的箱线图 )。 难道这涉及到升级到3.0 GGPLOT2?

注意
我真的不希望使用预先计算的值箱线图,我只是碰到这个问题开始回答上述问题时就来了。


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  

Answer 1:

我可以证实这一点(奇怪?)行为。

例如,如果我们这样做

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

我们得到一个警告

警告:忽略未知美学:宽度

但它实际上改变宽度

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

从相关的帖子评论ggplot -从汇总统计箱线图宽度[副本]表明,这并非总是如此。


样本数据

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))


文章来源: Width parameter and stat = 'identity' in geom_boxplot
标签: r ggplot2