You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

ggplot2 3.4.0中geom_hex()与stat_binhex()瓦片着色异常求助

ggplot2 3.4.0中六边形分箱功能颜色与瓦片坐标混淆问题

不确定这个问题从何时开始出现,但ggplot2 3.4.0里的geom_hex()和stat_binhex()两个六边形分箱功能,出现了颜色与瓦片坐标对应混乱的情况。相同数据下,方形分箱的stat_bin_2d()却能正常运行。

验证代码如下:

library(ggplot2)
library(ggpubr) # 用于ggarrange

d <- ggplot(diamonds, aes(carat, price))
ggarrange(d + geom_hex(), d + stat_bin_2d())

运行后可见,六边形分箱图呈现异常条纹图案,而右侧方形分箱图完全正常。此外,ggplot2在线文档的示例中也显示相同条纹,说明这并非本地环境独有的问题。

当前环境的sessionInfo:

> sessionInfo()

R version 4.1.2 (2021-11-01)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 22.04.1 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=fr_FR.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=fr_FR.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=fr_FR.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=fr_FR.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base      

other attached packages:
[1] ggpubr_0.5.0  ggplot2_3.4.0

loaded via a namespace (and not attached):
 [1] beeswarm_0.4.0    tidyselect_1.2.0  xfun_0.36         ica_1.0-3        
 [5] purrr_1.0.1       splines_4.1.2     lattice_0.20-45   carData_3.0-5    
 [9] colorspace_2.1-0  vctrs_0.5.2       generics_0.1.3    htmltools_0.5.4  
[13] viridisLite_0.4.1 yaml_2.3.7        mgcv_1.8-41       utf8_1.2.2       
[17] rlang_1.0.6       hexbin_1.28.2     pillar_1.8.1      glue_1.6.2       
[21] withr_2.5.0       pryr_0.1.6        lifecycle_1.0.3   stringr_1.5.0    
[25] munsell_0.5.0     ggsignif_0.6.4    gtable_0.3.1      codetools_0.2-18 
[29] evaluate_0.20     labeling_0.4.2    knitr_1.42        RAPToR_1.2.0     
[33] fastmap_1.1.0     parallel_4.1.2    fansi_1.0.4       Rcpp_1.0.10      
[37] broom_1.0.3       ROCR_1.0-11       scales_1.2.1      backports_1.4.1  
[41] limma_3.50.3      abind_1.4-5       farver_2.1.1      digest_0.6.31    
[45] stringi_1.7.12    rstatix_0.7.1     dplyr_1.1.0       rbibutils_2.2.13 
[49] grid_4.1.2        cowplot_1.1.1     Rdpack_2.4        cli_3.6.0        
[53] tools_4.1.2       magrittr_2.0.3    tibble_3.1.8      tidyr_1.3.0      
[57] car_3.1-1         pkgconfig_2.0.3   Matrix_1.5-3      data.table_1.14.6
[61] rmarkdown_2.20    rstudioapi_0.14   R6_2.5.1          nlme_3.1-161     
[65] compiler_4.1.2

恳请各位提供可行的解决办法。


内容的提问来源于stack exchange,提问作者RoB

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.01 02:35:26