tidyverse / ggplot2

An implementation of the Grammar of Graphics in R
https://ggplot2.tidyverse.org
Other
6.47k stars 2.02k forks source link

`geom_text()` justification docs are wrong #6033

Closed willgearty closed 5 days ago

willgearty commented 1 month ago

The justification docs on this page (?geom_text) are wrong (or at least misleading). These state that a value of 0 is right/bottom and a value of 1 is top/left. Whereas the specs here rightly state that 0 = bottom/left and 1 = top/right. I think the confusion comes from the fact that left justification moves items to the right and vice versa.

library(ggplot2)
ggplot(mtcars, aes(wt, mpg, label = rownames(mtcars))) +
    geom_point() +
    geom_text(hjust = 0)

ggplot(mtcars, aes(wt, mpg, label = rownames(mtcars))) +
    geom_point() +
    geom_text(hjust = 1)

Created on 2024-08-08 with reprex v2.1.1

teunbrand commented 1 month ago

Thanks for pointing this out! I agree that the docs should be consistent with itself and it is ?geom_text that is in the wrong here.