Skip to content

position_nudge doesn't work when called as position = "nudge" #1428

Closed
@garrettgman

Description

@garrettgman

Here's the example from ?position_nudge, which works.

df <- data.frame(
  x = c(1,3,2,5),
  y = c("a","c","d","c")
)

ggplot(df, aes(x, y)) +
  geom_point() +
  geom_text(aes(label = y))

ggplot(df, aes(x, y)) +
  geom_point() +
  geom_text(aes(label = y), position = position_nudge(y = -0.1))

But the code breaks when you call position = "nudge", as you might do with other positions.

ggplot(df, aes(x, y)) +
  geom_point() +
  geom_text(aes(label = y), position = "nudge")

There's no warning message, the text layer just disappears.

This is bad for me because I'd prefer to be able to teach beginners all five position adjustments without having to teach them the position = position_nudge() syntax. The second syntax is a bit overwhelming for someone new to R since it contains a function inside an argument. (We begin new R students with ggplot2 because visualizations are cool.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions