Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
821 views
in Technique[技术] by (71.8m points)

r - ggplot2: ..count.. not working with stat_bin_hex anymore

Some months ago I was able to produce the following plot without errors:

library(ggplot2)
library(hexbin)
x <- rnorm(100)
y <- rnorm(100, mean=2)
ggplot(data = data.frame(x,y)) +  stat_bin_hex(aes(x=x, y=y, alpha=..count..), fill="#ED1A3A", bins=10) 

Now this does not work anymore and I get the error

Error in eval(expr, envir, enclos) : Object 'count' not found

Any help how I get this working again and explanation why its not working anymore? Thanks!

EDIT 1: My session info in any case:

R version 3.2.3 (2015-12-10)
Platform: x86_64-apple-darwin14.5.0 (64-bit)
Running under: OS X 10.11.5 (El Capitan)

locale:
[1] de_DE.UTF-8/de_DE.UTF-8/de_DE.UTF-8/C/de_DE.UTF-8/de_DE.UTF-8

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

other attached packages:
 [1] hexbin_1.27.1       knitcitations_1.0.7 dplyr_0.4.3         XLConnect_0.2-11    XLConnectJars_0.2-9
 [6] data.table_1.9.6    scales_0.4.0        ggplot2_2.1.0       gridExtra_2.2.1     extrafont_0.17     
[11] np_0.60-2          

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.5        plyr_1.8.3         bitops_1.0-6       tools_3.2.3        boot_1.3-18       
 [6] digest_0.6.9       lattice_0.20-33    lubridate_1.5.6    gtable_0.2.0       bibtex_0.4.0      
[11] DBI_0.4-1          yaml_2.1.13        parallel_3.2.3     rJava_0.9-8        Rttf2pt1_1.3.4    
[16] knitr_1.13         stringr_1.0.0      httr_1.1.0         RefManageR_0.10.13 R6_2.1.2          
[21] XML_3.98-1.4       rmarkdown_0.9.6    RJSONIO_1.3-0      extrafontdb_1.0    magrittr_1.5      
[26] htmltools_0.3.5    assertthat_0.1     cubature_1.1-2     colorspace_1.2-6   labeling_0.3      
[31] stringi_1.0-1      RCurl_1.95-4.8     lazyeval_0.1.10    munsell_0.4.3      chron_2.3-47      

EDIT 2: Interestingly it still works with stat_bin_2d.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

This seems to be related to the open issue

geom_hex no longer recognizes ..density.. in 2.1.0 #1608

(Github)

that seems to have to fix, yet.


Update 2016-09-18: Check out this answer on Stackoverflow.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...