We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
If label column has date values, geom_label_repel doesn't work. geom_label does work with dates.
Here is the minimum amount of code needed to demonstrate the issue:
library(tibble) library(ggplot2) library(ggrepel) library(gridExtra) # Create data sets with date or text label column plotdata_w_date <- tibble(x = as.Date(c("2021-01-01", "2021-01-02", "2021-01-03")), y = c(1, 2, 3), label = as.Date(c(NA, "2021-01-02", NA))) plotdata_w_date #> # A tibble: 3 x 3 #> x y label #> <date> <dbl> <date> #> 1 2021-01-01 1 NA #> 2 2021-01-02 2 2021-01-02 #> 3 2021-01-03 3 NA plotdata_w_text <- tibble(x = as.Date(c("2021-01-01", "2021-01-02", "2021-01-03")), y = c(1, 2, 3), label = as.character(as.Date(c(NA, "2021-01-02", NA)))) plotdata_w_text #> # A tibble: 3 x 3 #> x y label #> <date> <dbl> <chr> #> 1 2021-01-01 1 <NA> #> 2 2021-01-02 2 2021-01-02 #> 3 2021-01-03 3 <NA> # Plot both data with geom_label and geom_label_repel p1 <- ggplot(plotdata_w_date, aes(x = x, y = y, label = label)) + geom_point() + geom_label() + ggtitle("geom_label() with date") p2 <- ggplot(plotdata_w_date, aes(x = x, y = y, label = label)) + geom_point() + geom_label_repel() + ggtitle("geom_label_repel() with date") p3 <- ggplot(plotdata_w_text, aes(x = x, y = y, label = label)) + geom_point() + geom_label() + ggtitle("geom_label() with text") p4 <- ggplot(plotdata_w_text, aes(x = x, y = y, label = label)) + geom_point() + geom_label_repel() + ggtitle("geom_label_repel() with text") grid.arrange(p1, p2, p3, p4, ncol = 2, nrow = 2) #> Warning: Removed 2 rows containing missing values (geom_label). #> Warning: Removed 2 rows containing missing values (geom_label_repel). #> Warning: Removed 2 rows containing missing values (geom_label). #> Warning: Removed 2 rows containing missing values (geom_label_repel).
Here is an image of the output produced by the code:
It would be nice if geom_label_repel would work with date values like geom_label
Here is the output from sessionInfo() in my R session:
sessionInfo()
sessionInfo() #> R version 4.0.3 (2020-10-10) #> Platform: x86_64-pc-linux-gnu (64-bit) #> Running under: Ubuntu 20.04.1 LTS #> #> Matrix products: default #> BLAS/LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.8.so #> #> 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=C #> [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 datasets utils methods base #> #> other attached packages: #> [1] gridExtra_2.3 ggrepel_0.9.1 ggplot2_3.3.3 tibble_3.1.0 #> #> loaded via a namespace (and not attached): #> [1] Rcpp_1.0.6 knitr_1.31 magrittr_2.0.1 munsell_0.5.0 #> [5] colorspace_2.0-0 R6_2.5.0 rlang_0.4.10 fansi_0.4.2 #> [9] stringr_1.4.0 styler_1.4.0 highr_0.8 tools_4.0.3 #> [13] grid_4.0.3 gtable_0.3.0 xfun_0.22 utf8_1.2.1 #> [17] withr_2.4.1 htmltools_0.5.1.1 ellipsis_0.3.1 yaml_2.2.1 #> [21] digest_0.6.27 lifecycle_1.0.0 crayon_1.4.1 purrr_0.3.4 #> [25] vctrs_0.3.6 fs_1.5.0 glue_1.4.2 evaluate_0.14 #> [29] rmarkdown_2.7 reprex_1.0.0 stringi_1.5.3 compiler_4.0.3 #> [33] pillar_1.5.1 scales_1.1.1 backports_1.2.1 renv_0.13.1 #> [37] pkgconfig_2.0.3
The text was updated successfully, but these errors were encountered:
Thanks for opening the issue and sharing the code and figure.
Sorry, something went wrong.
No branches or pull requests
Summary
If label column has date values, geom_label_repel doesn't work. geom_label does work with dates.
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:
Suggestions
It would be nice if geom_label_repel would work with date values like geom_label
Version information
Here is the output from
sessionInfo()
in my R session:The text was updated successfully, but these errors were encountered: