eclarke / ggbeeswarm

Column scatter / beeswarm-style plots in ggplot2

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

geom_beeswarm not plotting with latest dev version

csdaw opened this issue ยท comments

Hi there,

I can't seem to get geom_beeswarm to plot any points. I am running ggbeeswarm v0.7.0 and ggplot2 v3.3.2. The CRAN version is working fine.

From what I can tell the issue is due to the makeContent.beeswarm() function not being called at all.

library(ggplot2)
library(ggbeeswarm)

distro <- data.frame(
  'variable'=rep(c('runif','rnorm'),each=100),
  'value'=c(runif(100, min=-3, max=3), rnorm(100))
)

ggplot2::ggplot(distro,aes(variable, value)) +
  geom_beeswarm(priority='density',size=2.5)

sessionInfo()
#> R version 4.0.0 (2020-04-24)
#> Platform: x86_64-apple-darwin17.0 (64-bit)
#> Running under: macOS Catalina 10.15.5
#> 
#> Matrix products: default
#> BLAS:   /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRblas.dylib
#> LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib
#> 
#> locale:
#> [1] en_AU.UTF-8/en_AU.UTF-8/en_AU.UTF-8/C/en_AU.UTF-8/en_AU.UTF-8
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#> [1] ggbeeswarm_0.7.0 ggplot2_3.3.2   
#> 
#> loaded via a namespace (and not attached):
#>  [1] knitr_1.28       magrittr_1.5     tidyselect_1.1.0 munsell_0.5.0   
#>  [5] colorspace_1.4-1 R6_2.4.1         rlang_0.4.6      vipor_0.4.5     
#>  [9] dplyr_1.0.0      stringr_1.4.0    highr_0.8        tools_4.0.0     
#> [13] grid_4.0.0       beeswarm_0.2.3   gtable_0.3.0     xfun_0.14       
#> [17] withr_2.2.0      htmltools_0.5.0  ellipsis_0.3.1   yaml_2.2.1      
#> [21] digest_0.6.25    tibble_3.0.1     lifecycle_0.2.0  crayon_1.3.4    
#> [25] farver_2.0.3     purrr_0.3.4      vctrs_0.3.1      glue_1.4.1      
#> [29] evaluate_0.14    rmarkdown_2.2    labeling_0.3     stringi_1.4.6   
#> [33] compiler_4.0.0   pillar_1.4.4     generics_0.0.2   scales_1.1.1    
#> [37] pkgconfig_2.0.3

Created on 2020-06-27 by the reprex package (v0.3.0)

This could potentially be a problem with the package in R 4.0.0 since it seems to run for me in 3.6.3. I'll try it on 4.0.0 shortly.

test

R version 3.6.3 (2020-02-29)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.4 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.7.1
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.7.1

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

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

other attached packages:
[1] ggbeeswarm_0.7.0 ggplot2_3.3

Yeah it looks like a 4.0.0 problem. Thanks for catching that. I'll look into it.
test

R version 4.0.2 (2020-06-22)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.4 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.7.1
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.7.1

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

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

other attached packages:
[1] ggbeeswarm_0.7.0 ggplot2_3.3.2  

I indirectly solved my problem by just rewriting the geom_beeswarm function from scratch (example plot here).

This doesn't actually solve the problem above but, given the CRAN version of ggbeeswarm works fine R >= v.4.0.0, I think this issue can be closed.

@csdaw

Thanks! This just saved my day. Your comment here is not easy to find - maybe advertising your fork in a new issue in the repo could help users?

It seems the initial R package has been abandoned.

Thanks for bumping this, @pat-s. I'd prefer the term "neglected" rather than "abandoned"- but either way will work on remedying that :) I'll start with pointing folks to this fork in the readme.

@csdaw, if you'd like, I'd be happy to incorporate your changes into this package. If you want to do that, since you mention on the readme that it's under active development, I'm open to merging pull requests for stat_beeswarm on an ongoing basis.

@eclarke

Sorry, wasn't meant to be offensive ;)

I just don't know of other words than this to describe such a state ๐Ÿ™‚

My comment was only intended to help visibility of the fix for others.
If you fix it upstream, this is even better.
And if my comment caused this partly, I am happy to be blamed ๐Ÿ˜ฌ

Thanks for the package and your time ๐Ÿ‘

Oh no offense taken at all- I intended my comment to be more of a self-deprecating joke ๐Ÿ˜
I really do appreciate you and everybody else who takes the time to give feedback on these issues. Hopefully we'll be able to resolve them soon- just need to carve out some time to do so.

@pat-s Thanks for the bump, glad I could help :)

@eclarke I'd be pleased to contribute my changes to ggbeeswarm.
The README in my (relatively opinionated) fork is a bit out of date as I'd say its now in a "stable" state and I don't intend to add anything else to it.

In any case if you're okay with it, I can make some PRs to a) refactor the geom/position beeswarm and quasirandom functions so they work more cleanly, and b) add in the extra beeswarm method and corral options.