Skip to content

Typo in help text for ?geom_text Alignment #6455

@gregorp

Description

@gregorp

The Alignment section of geom_text discussing hjust and vjust says

... the vjust and hjust aesthetics. These can either be a number between 0 (right/bottom) and 1 (top/left)...

But this is incorrect: hjust = 0 gives left alignment, and hjust = 1 gives right alignment.

As a more minor quibble, it would be good form to maintain a consistent order of (vjust/hjust). Recommend correcting it to

These can either be a number between 0 (bottom/left) and 1 (top/right)...


Quick reprex from this Stack Overflow answer

library(ggplot2)
hjust_data = data.frame(z = paste("hjust =", c(0, 0.5, 1)))
df = data.frame(x = 1:5, y = 1:5)
df = merge(df, hjust_data, all = TRUE)

text_df = subset(df, x == 3) |>
  transform(lab = "Your nice\nmultiple line text\nis here")

ggplot(df, aes(x, y)) +
  geom_point() +
  facet_wrap(vars(z), ncol = 1) +
  geom_text(aes(label = lab), data = text_df[1, ], hjust = 0) +
  geom_text(aes(label = lab), data = text_df[2, ], hjust = 0.5) +
  geom_text(aes(label = lab), data = text_df[3, ], hjust = 1)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions