Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minor_breaks with Dates #1385

Closed
ptoche opened this issue Oct 23, 2015 · 1 comment
Closed

minor_breaks with Dates #1385

ptoche opened this issue Oct 23, 2015 · 1 comment
Labels
Milestone

Comments

@ptoche
Copy link

@ptoche ptoche commented Oct 23, 2015

Is the following expected behaviour? (scroll down to the last example, which fails)

    df <- data.frame(
        x_date  = seq(as.Date("1952-01-01"), as.Date("2013-12-01"), by = "1 month"),
        y = runif(12*62)
    )
    library('ggplot2')
    library('scales')
    p <- ggplot(df, aes(x_date, y)) + geom_point()

    # version 1: automatic selection of start/end 'major' breaks
    p + scale_x_date(labels = date_format("%Y"), 
                     breaks = "5 years", 
                     minor_breaks = "1 year")

    # version 2: manual selection of start/end 'major' breaks
    p + scale_x_date(labels = date_format("%Y"), 
                     breaks = seq(as.Date("1950-01-01"), 
                                  as.Date("2015-01-01"), 
                                  by = "5 years"),
                     minor_breaks = "1 year")

    # version 3: manual selection of start/end 'minor' breaks: FAIL
    p + scale_x_date(labels = date_format("%Y"), 
                     breaks = seq(as.Date("1950-01-01"), 
                                  as.Date("2015-01-01"), 
                                  by = "5 years"),
                     minor_breaks = seq(as.Date("1975-01-01"), 
                                  as.Date("1995-01-01"), 
                                  by = "1 year"))
    ## Error in Ops.Date((x - from[1]), diff(from)) : 
    ##  / not defined for "Date" objects
@hadley hadley closed this in 233a11b Nov 9, 2015
@hadley hadley added the bug label Nov 9, 2015
@hadley hadley added this to the v1.1.0 milestone Nov 9, 2015
@hadley
Copy link
Member

@hadley hadley commented Nov 9, 2015

This was a pretty major bug affecting minor_breaks whenever you used a transformed scale.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants