Skip to content

Multiple nudge arguments results in warning #2977

@steffilazerte

Description

@steffilazerte

The documentation for 'position_nudge' implies that you should only give one value for nudge, but isn't explicit. I often give different nudge values for each label so I can nudge them in different directions.

This works, but results in a warning. I would suggest fixing the if() statement to check multiple values, or make it explicit that we shouldn't be using more than one nudge value.

Thanks!

library(ggplot2)

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), nudge_y = c(-0.1, 0.1, -0.1, -0.1))

#> Warning in if (params$y != 0) {: the condition has length > 1 and only the
#> first element will be used

Created on 2018-11-01 by the reprex package (v0.2.1)

Metadata

Metadata

Assignees

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