Skip to content

date_breaks and date_breaks minor don't check argument type #5880

Closed
@botanize

Description

@botanize

datetime_scales accepts any argument type for date_breaks and date_minor_breaks, but the parameter documentation claims it only accepts character strings. It's somewhat easy to accidentally supply custom date breaks using scales::breaks_width to the wrong parameter (date_breaks instead of breaks), after all, you're defining date-breaks either way.

I expected an error that the date_breaks parameter had the wrong type, instead I got the unhelpful: Error in strsplit(unitspec, " ") : non-character argument.

ggplot(economics, aes(date, unemploy)) + 
  geom_line() + 
  scale_x_date(date_breaks = scales::breaks_width('10 years', offset = '6 months')

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions