-
-
Notifications
You must be signed in to change notification settings - Fork 93
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
Texts created using geom_text_repel() in ggplot2 disappear when the plot is flipped using coord_flip(). #253
Comments
Thanks for sharing the example code and figure! I think this is probably due to the recent change to make ggrepel compatible with ggbreak (see here for more details). I wonder if there is an easy fix... pull requests are very welcome. |
If it helps, I observed the same issue when applying a transformation to the coordinates. See example below: library(ggrepel)
library(scales)
ggplot(mtcars, aes(wt, mpg, label = rownames(mtcars))) +
geom_text_repel() +
geom_point(color = 'red') +
theme_classic(base_size = 16) +
coord_trans(y = pseudo_log_trans(base = 2, sigma = 0.1)) |
Thanks @rrrrrhhhhh it's always helpful to have additional test cases. I think I might need to revert the code back to an earlier version, and drop support for ggbreak. The coordinate transformation seems more important to me than compatibility with ggbreak. |
This issue should be fixed by this commit in the latest development version. library(ggrepel)
#> Loading required package: ggplot2
library(scales)
# example 1
ggplot(mtcars, aes(wt, mpg, label = rownames(mtcars))) +
geom_text_repel() +
geom_point(color = 'red') +
theme_classic(base_size = 16) +
coord_flip()
#> Warning: ggrepel: 2 unlabeled data points (too many overlaps). Consider
#> increasing max.overlaps # example 2
p <- ggplot(mtcars, aes(wt, mpg, label = rownames(mtcars))) +
geom_text_repel() +
geom_point(color = 'red') +
theme_classic(base_size = 16)
p
#> Warning: ggrepel: 2 unlabeled data points (too many overlaps). Consider
#> increasing max.overlaps p + scale_x_continuous(limits = c(NA, 3))
#> Warning: Removed 20 rows containing missing values or values outside the scale range
#> (`geom_text_repel()`).
#> Warning: Removed 20 rows containing missing values or values outside the scale range
#> (`geom_point()`). p + coord_trans(y = pseudo_log_trans(base = 2, sigma = 0.1)) Created on 2024-05-16 with reprex v2.0.2 Session infosessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#> setting value
#> version R version 4.2.3 (2023-03-15)
#> os macOS Ventura 13.4
#> system aarch64, darwin20
#> ui X11
#> language (EN)
#> collate en_US.UTF-8
#> ctype en_US.UTF-8
#> tz America/New_York
#> date 2024-05-16
#> pandoc 3.1.11 @ /Applications/RStudio.app/Contents/Resources/app/quarto/bin/tools/aarch64/ (via rmarkdown)
#>
#> ─ Packages ───────────────────────────────────────────────────────────────────
#> package * version date (UTC) lib source
#> cli 3.6.2 2023-12-11 [1] CRAN (R 4.2.3)
#> colorspace 2.1-0 2023-01-23 [1] CRAN (R 4.2.0)
#> curl 5.2.1 2024-03-01 [1] CRAN (R 4.2.3)
#> digest 0.6.31 2022-12-11 [1] CRAN (R 4.2.0)
#> dplyr 1.1.4 2023-11-17 [1] CRAN (R 4.2.3)
#> evaluate 0.21 2023-05-05 [1] CRAN (R 4.2.0)
#> fansi 1.0.6 2023-12-08 [1] CRAN (R 4.2.3)
#> farver 2.1.1 2022-07-06 [1] CRAN (R 4.2.0)
#> fastmap 1.1.1 2023-02-24 [1] CRAN (R 4.2.0)
#> fs 1.6.2 2023-04-25 [1] CRAN (R 4.2.0)
#> generics 0.1.3 2022-07-05 [1] CRAN (R 4.2.0)
#> ggplot2 * 3.5.1 2024-04-23 [1] CRAN (R 4.2.3)
#> ggrepel * 0.9.5.9999 2024-05-16 [1] local
#> glue 1.7.0 2024-01-09 [1] CRAN (R 4.2.3)
#> gtable 0.3.4 2023-08-21 [1] CRAN (R 4.2.0)
#> highr 0.10 2022-12-22 [1] CRAN (R 4.2.0)
#> htmltools 0.5.5 2023-03-23 [1] CRAN (R 4.2.0)
#> knitr 1.43 2023-05-25 [1] CRAN (R 4.2.0)
#> labeling 0.4.3 2023-08-29 [1] CRAN (R 4.2.0)
#> lifecycle 1.0.4 2023-11-07 [1] CRAN (R 4.2.3)
#> magrittr 2.0.3 2022-03-30 [1] CRAN (R 4.2.0)
#> munsell 0.5.0 2018-06-12 [1] CRAN (R 4.2.0)
#> pillar 1.9.0 2023-03-22 [1] CRAN (R 4.2.0)
#> pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.2.0)
#> purrr 1.0.2 2023-08-10 [1] CRAN (R 4.2.0)
#> R.cache 0.16.0 2022-07-21 [1] CRAN (R 4.2.0)
#> R.methodsS3 1.8.2 2022-06-13 [1] CRAN (R 4.2.0)
#> R.oo 1.26.0 2024-01-24 [1] CRAN (R 4.2.3)
#> R.utils 2.12.3 2023-11-18 [1] CRAN (R 4.2.3)
#> R6 2.5.1 2021-08-19 [1] CRAN (R 4.2.0)
#> Rcpp 1.0.11 2023-07-06 [1] CRAN (R 4.2.0)
#> reprex 2.0.2 2022-08-17 [1] CRAN (R 4.2.0)
#> rlang 1.1.3 2024-01-10 [1] CRAN (R 4.2.3)
#> rmarkdown 2.23 2023-07-01 [1] CRAN (R 4.2.0)
#> rstudioapi 0.15.0 2023-07-07 [1] CRAN (R 4.2.0)
#> scales * 1.3.0 2023-11-28 [1] CRAN (R 4.2.3)
#> sessioninfo 1.2.2 2021-12-06 [1] CRAN (R 4.2.0)
#> styler 1.10.2 2023-08-29 [1] CRAN (R 4.2.0)
#> tibble 3.2.1 2023-03-20 [1] CRAN (R 4.2.0)
#> tidyselect 1.2.1 2024-03-11 [1] CRAN (R 4.2.3)
#> utf8 1.2.4 2023-10-22 [1] CRAN (R 4.2.0)
#> vctrs 0.6.5 2023-12-01 [1] CRAN (R 4.2.3)
#> withr 3.0.0 2024-01-16 [1] CRAN (R 4.2.3)
#> xfun 0.39 2023-04-20 [1] CRAN (R 4.2.0)
#> xml2 1.3.4 2023-04-27 [1] CRAN (R 4.2.0)
#> yaml 2.3.7 2023-01-23 [1] CRAN (R 4.2.0)
#>
#> [1] /Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library
#>
#> ────────────────────────────────────────────────────────────────────────────── |
Summary
Texts created using geom_text_repel() in ggplot2 disappear when the plot is flipped using coord_flip().
Minimal code example
Here is the minimum amount of code needed to demonstrate the issue:
Here is an image of the output produced by the code:
Possible Workaround
Using prior version ggrepel_0.9.2
Version information
Here is the output from
sessionInfo()
in my R session:The text was updated successfully, but these errors were encountered: