ggplot2 icon indicating copy to clipboard operation
ggplot2 copied to clipboard

Confusing error when `theme(legend.direction = .)` incorrectly entered

Open ngreifer opened this issue 3 years ago • 0 comments

When running ggplot() with a legend and using theme(legend.position = .) to change the legend direction, an invalid argument causes an unclear error. I also feel like abbreviations should be allowed for this argument since it only accepts two strings.

library(ggplot2)
ggplot(mpg, aes(x = cty, fill = drv)) +
  geom_histogram() +
  theme(legend.direction = "v")

## Error in if (!g$title.position %in% c("top", "bottom", "left", "right")) { : 
##  argument is of length zero

ngreifer avatar Aug 04 '22 19:08 ngreifer