MattCowgill / ggannotate

Interactively annotate ggplots
Other
309 stars 20 forks source link

`factor()` in `facet_*()` breaks mapping #22

Closed MattCowgill closed 3 years ago

MattCowgill commented 4 years ago

For example, executing this results in annotation being placed in every facet:

p <- mtcars %>%
  ggplot(aes(x = wt, y = mpg)) +
  geom_point() +
  facet_wrap(~factor(cyl))

ggannotate(p)

This works:

p <- mtcars %>%
  mutate(cyl = factor(cyl)) %>%
  ggplot(aes(x = wt, y = mpg)) +
  geom_point() +
  facet_wrap(~cyl)

ggannotate(p)