Skip to content

Breaks misalignment with scale_x_date #814

@jrowen

Description

@jrowen

I'm seeing a misalignment between the major and minor breaks when they use different units.

df=data.frame(Date=seq(from=as.Date("2008-12-15"), 
                     to=as.Date("2013-04-30"), by="day"))
df$y=rnorm(nrow(df))

ggplot(df) +
  geom_path(aes(x=Date, y=y)) +
  scale_x_date(expand=c(0, 0), breaks=date_breaks("1 year"), 
               labels=date_format("%Y"),
               minor_breaks=date_breaks("3 months"))

If everything is defined using the same units, the breaks are aligned as expected, but in this example, the axis label marks the end, instead of beginning of the period.

ggplot(df) +
  geom_path(aes(x=Date, y=y)) +
  scale_x_date(expand=c(0, 0), breaks=date_breaks("12 months"), 
               labels=date_format("%Y"),
               minor_breaks=date_breaks("3 months"))

Metadata

Metadata

Assignees

No one assigned

    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