Skip to content

Breaks should be computed on pre-expanded range #3592

Closed

Description

@hadley

Otherwise when you adjust the number of breaks, you can end up with breaks right on the margin of the plot

library(ggplot2)

may01 <- as.POSIXct("2020-05-01")
df <- data.frame(x = c(may01, may01 + 60 * 86400))

ggplot(df, aes(x, 1)) + 
  geom_blank() + 
  scale_x_datetime(NULL, date_breaks = "7 days", date_labels = "%d %b") + 
  scale_y_continuous(NULL, breaks = NULL)

Created on 2019-10-27 by the reprex package (v0.3.0)

Activity

  1. paleolimbot commented on Oct 27, 2019

    @paleolimbot
    Member

    This would also solve #980, although having implemented this at least once, I seem to remember that most of the test case plots looked better when the breaks were computed on the expanded range.

  2. added
    visual change 👩‍🎨
    on Jan 21, 2020
  3. thomasp85 commented on Nov 19, 2024

    @thomasp85
    Member

    Closing this for now as it is not clear it will be a universally better solution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    internals 🔎scales 🐍visual change 👩‍🎨

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions