-
-
Notifications
You must be signed in to change notification settings - Fork 94
Open
Labels
Description
Summary
This is a bug originally in 'ggplot2', and fixed by a pull request submitted today. There is an additional problem of inconsistency in the direction for "inward" and "outward" and "right" and "left" between 'ggrepel' and 'ggplot2'.
Minimal code example
Here are some examples of code needed to demonstrate the issue:
library(ggplot2)
library(ggrepel)
my.cars <- mtcars[c(TRUE, FALSE, FALSE, FALSE), ]
p <- ggplot(my.cars, aes(wt, mpg, label = rownames(my.cars))) +
geom_point(colour = "red")
# problem 1 opposite direction for geom_text() and geom_text_repel()
p + geom_text(hjust = "outward")p + geom_text_repel(hjust = "outward")p + geom_text(hjust = "inward")p + geom_text_repel(hjust = "inward")# Angles > 45 degrees or < -45 degrees
# Same problem as the one now fixed in 'ggplt2'
p + geom_text_repel(hjust = "outward", angle = 30)p + geom_text_repel(hjust = "inward", angle = 30)p + geom_text_repel(hjust = "outward", angle = 70)p + geom_text_repel(hjust = "inward", angle = 70)p + geom_text_repel(hjust = "outward", angle = 90)p + geom_text_repel(hjust = "inward", angle = 90)p + geom_text_repel(hjust = "outward", angle = -90)p + geom_text_repel(hjust = "inward", angle = -90)Created on 2021-05-04 by the reprex package (v2.0.0)
Suggestions
As soon as the pull request is accepted in 'ggplot2' I will submit the matching pull request for 'ggrepel'.
I suggest at the same time making the response to "inward" and "outward" and "left" and "right" the same as in 'ggplot2' instead of opposite. See examples above.
Version information
Here is the output from sessionInfo() in my R session:
R version 4.0.5 (2021-03-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19042)
Matrix products: default
locale:
[1] LC_COLLATE=English_Finland.1252 LC_CTYPE=English_Finland.1252
[3] LC_MONETARY=English_Finland.1252 LC_NUMERIC=C
[5] LC_TIME=English_Finland.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] shiny_1.6.0 ggrepel_0.9.1.9999 ggplot2_3.3.3.9000
loaded via a namespace (and not attached):
[1] styler_1.4.1 tidyselect_1.1.0 xfun_0.22 bslib_0.2.4
[5] purrr_0.3.4 colorspace_2.0-0 vctrs_0.3.8 generics_0.1.0
[9] miniUI_0.1.1.1 htmltools_0.5.1.1 yaml_2.2.1 utf8_1.2.1
[13] rlang_0.4.10 later_1.2.0 pillar_1.6.0 jquerylib_0.1.4
[17] glue_1.4.2 withr_2.4.2 DBI_1.1.1 lifecycle_1.0.0
[21] munsell_0.5.0 gtable_0.3.0 evaluate_0.14 labeling_0.4.2
[25] knitr_1.33 callr_3.7.0 fastmap_1.1.0 ps_1.6.0
[29] httpuv_1.6.0 parallel_4.0.5 fansi_0.4.2 highr_0.9
[33] Rcpp_1.0.6 xtable_1.8-4 clipr_0.7.1 scales_1.1.1
[37] promises_1.2.0.1 backports_1.2.1 cachem_1.0.4 jsonlite_1.7.2
[41] mime_0.10 farver_2.1.0 fs_1.5.0 digest_0.6.27
[45] processx_3.5.1 dplyr_1.0.5 grid_4.0.5 cli_2.5.0
[49] tools_4.0.5 magrittr_2.0.1 sass_0.3.1 tibble_3.1.1
[53] crayon_1.4.1 pkgconfig_2.0.3 ellipsis_0.3.2 reprex_2.0.0
[57] rmarkdown_2.7 assertthat_0.2.1 rstudioapi_0.13 R6_2.5.0
[61] compiler_4.0.5
slowkow











