Skip to content

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

Closed
@ngreifer

Description

@ngreifer

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    messagesrequests for improvements to error, warning, or feedback messages

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions