New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bizarre difference between locations of geom_text vs. geom_label? #182
Comments
FYI, adding So I solved my immediate problem, but it still seems weird that the two functions behave differently. I'm leaving this open in case you want to pursue it further. |
Thanks for reporting the issue! I appreciate it. I can't run your code, because I don't have your data. Please consider sharing an example that I can run on my own computer. Here's what I see: library(ggrepel)
#> Loading required package: ggplot2
cars <- mtcars
cars$car <- rownames(cars)
cars$car[1:(nrow(cars)-2)] <- NA
p <- ggplot(cars, aes(x = wt, y = mpg)) +
geom_jitter(aes(color = is.na(car))) +
geom_smooth()
p + geom_text_repel(aes(label = car))
#> `geom_smooth()` using method = 'loess' and formula 'y ~ x'
#> Warning: Removed 30 rows containing missing values (geom_text_repel). p + geom_label_repel(aes(label = car))
#> `geom_smooth()` using method = 'loess' and formula 'y ~ x'
#> Warning: Removed 30 rows containing missing values (geom_label_repel). Created on 2021-01-09 by the reprex package (v0.3.0) Session infodevtools::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#> setting value
#> version R version 4.0.3 (2020-10-10)
#> os macOS Catalina 10.15.7
#> system x86_64, darwin17.0
#> ui X11
#> language (EN)
#> collate en_US.UTF-8
#> ctype en_US.UTF-8
#> tz America/New_York
#> date 2021-01-09
#>
#> ─ Packages ───────────────────────────────────────────────────────────────────
#> package * version date lib source
#> assertthat 0.2.1 2019-03-21 [2] CRAN (R 4.0.2)
#> callr 3.5.1 2020-10-13 [2] CRAN (R 4.0.2)
#> cli 2.2.0 2020-11-20 [2] CRAN (R 4.0.2)
#> colorspace 2.0-0 2020-11-11 [2] CRAN (R 4.0.2)
#> crayon 1.3.4 2017-09-16 [2] CRAN (R 4.0.2)
#> curl 4.3 2019-12-02 [2] CRAN (R 4.0.1)
#> desc 1.2.0 2018-05-01 [2] CRAN (R 4.0.2)
#> devtools 2.3.0 2020-04-10 [2] CRAN (R 4.0.2)
#> digest 0.6.27 2020-10-24 [2] CRAN (R 4.0.2)
#> dplyr 1.0.2 2020-08-18 [2] CRAN (R 4.0.2)
#> ellipsis 0.3.1 2020-05-15 [2] CRAN (R 4.0.2)
#> evaluate 0.14 2019-05-28 [2] CRAN (R 4.0.1)
#> fansi 0.4.1 2020-01-08 [2] CRAN (R 4.0.2)
#> farver 2.0.3 2020-01-16 [2] CRAN (R 4.0.2)
#> fs 1.5.0 2020-07-31 [1] CRAN (R 4.0.2)
#> generics 0.1.0 2020-10-31 [2] CRAN (R 4.0.2)
#> ggplot2 * 3.3.2.9000 2020-12-08 [2] Github (tidyverse/ggplot2@b5cc4d6)
#> ggrepel * 0.9.0.9999 2021-01-04 [1] local
#> glue 1.4.2 2020-08-27 [2] CRAN (R 4.0.2)
#> gtable 0.3.0 2019-03-25 [2] CRAN (R 4.0.2)
#> highr 0.8 2019-03-20 [2] CRAN (R 4.0.2)
#> htmltools 0.5.0 2020-06-16 [2] CRAN (R 4.0.2)
#> httr 1.4.2 2020-07-20 [2] CRAN (R 4.0.2)
#> knitr 1.30 2020-09-22 [1] CRAN (R 4.0.2)
#> labeling 0.4.2 2020-10-20 [2] CRAN (R 4.0.2)
#> lattice 0.20-41 2020-04-02 [2] CRAN (R 4.0.3)
#> lifecycle 0.2.0 2020-03-06 [2] CRAN (R 4.0.2)
#> magrittr 2.0.1.9000 2020-12-15 [1] Github (tidyverse/magrittr@bb1c86a)
#> Matrix 1.2-18 2019-11-27 [2] CRAN (R 4.0.3)
#> memoise 1.1.0.9000 2020-12-15 [1] Github (r-lib/memoise@0901e3f)
#> mgcv 1.8-33 2020-08-27 [2] CRAN (R 4.0.3)
#> mime 0.9 2020-02-04 [2] CRAN (R 4.0.2)
#> munsell 0.5.0 2018-06-12 [2] CRAN (R 4.0.2)
#> nlme 3.1-149 2020-08-23 [2] CRAN (R 4.0.3)
#> pillar 1.4.7 2020-11-20 [2] CRAN (R 4.0.2)
#> pkgbuild 1.1.0 2020-07-13 [2] CRAN (R 4.0.2)
#> pkgconfig 2.0.3 2019-09-22 [2] CRAN (R 4.0.2)
#> pkgload 1.1.0 2020-05-29 [2] CRAN (R 4.0.2)
#> prettyunits 1.1.1 2020-01-24 [2] CRAN (R 4.0.2)
#> processx 3.4.5 2020-11-30 [2] CRAN (R 4.0.2)
#> ps 1.5.0 2020-12-05 [2] CRAN (R 4.0.2)
#> purrr 0.3.4 2020-04-17 [2] CRAN (R 4.0.2)
#> R6 2.5.0 2020-10-28 [2] CRAN (R 4.0.2)
#> Rcpp 1.0.5.4 2020-12-08 [2] Github (RcppCore/Rcpp@a72a27c)
#> remotes 2.2.0 2020-07-21 [1] CRAN (R 4.0.2)
#> rlang 0.4.9 2020-11-26 [2] CRAN (R 4.0.2)
#> rmarkdown 2.3.2 2020-07-17 [2] Github (rstudio/rmarkdown@ff1b279)
#> rprojroot 2.0.2 2020-11-15 [2] CRAN (R 4.0.2)
#> scales 1.1.1 2020-05-11 [2] CRAN (R 4.0.2)
#> sessioninfo 1.1.1 2018-11-05 [2] CRAN (R 4.0.2)
#> stringi 1.5.3 2020-09-09 [2] CRAN (R 4.0.2)
#> stringr 1.4.0 2019-02-10 [2] CRAN (R 4.0.2)
#> testthat 3.0.0 2020-10-31 [2] CRAN (R 4.0.2)
#> tibble 3.0.4 2020-10-12 [2] CRAN (R 4.0.2)
#> tidyselect 1.1.0 2020-05-11 [2] CRAN (R 4.0.2)
#> usethis 1.6.1 2020-04-29 [2] CRAN (R 4.0.2)
#> vctrs 0.3.5 2020-11-17 [2] CRAN (R 4.0.2)
#> withr 2.3.0 2020-09-22 [2] CRAN (R 4.0.2)
#> xfun 0.19 2020-10-30 [1] CRAN (R 4.0.2)
#> xml2 1.3.2 2020-04-23 [2] CRAN (R 4.0.2)
#> yaml 2.2.1 2020-02-01 [2] CRAN (R 4.0.2)
#>
#> [1] /Users/kamil/Library/R/4.0/library
#> [2] /Library/Frameworks/R.framework/Versions/4.0/Resources/library |
|
Hm... I think I might be seeing the same strange behavior you reported. It's difficult to make a reproducible example, though! |
I just pushed 8adf073 While I can't make an example that looks similar to yours, I did notice that this commit seemed to change the way Could I please ask you to try running your example again with this the GitHub version of ggrepel? remotes::install_github("slowkow/ggrepel@8adf073")
# run your example again ... Thanks again for your report! I don't usually use |
Thanks for the quick response! I still see the problem persisting in the patch you mentioned. I can also confirm that the behavior does NOT occur in v0.8.2. It looks like |
I was able to reproduce your example after installing an old version of Thanks again. I'll let you know when I figure out what is going on... |
@beanumber I found a bug and fixed it! Thank you so much. That was an important bug, so I plan to push a fix to CRAN soon. |
Glad to be of service. Thanks for everything you've put into this! |
Summary
geom_label_repel()
is placing labels in strange locations that are very far from the (correct)geom_text_repel()
placements. This behavior appears to be new in v0.9.0.Minimal code example
Created on 2021-01-09 by the reprex package (v0.3.0)
The text was updated successfully, but these errors were encountered: