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

Pretty date breaks #5

Closed
hadley opened this issue Jun 6, 2009 · 4 comments
Closed

Pretty date breaks #5

hadley opened this issue Jun 6, 2009 · 4 comments

Comments

@hadley
Copy link
Member

hadley commented Jun 6, 2009

Need method like pretty() from base R that given a date range, provides a set of pretty breaks that nicely span the range.

@hadley
Copy link
Member Author

hadley commented Jun 30, 2009

See ggplot2::time_breaks and ggplot2::date_breaks for a place to start.

@garrettgman
Copy link
Member

could you give me a better understanding of what pretty dates should accomplish? ggplot2::date_breaks returns an output that seems tailored for another function to use. (It doesn't seem that understandable on its own). What overall process is pretty dates a step in? Binning histograms? Also, what determines whether a date break is pretty (i.e, a certain number of them, breaks falling on round "numbers/dates", etc)?

@garrettgman
Copy link
Member

I made a pretty.dates() with the following features:

  1. identifies the unit each interval should be in to provide ~ n bins
  2. chooses a "pretty" length for the intervals depending on their units
    An interval is "pretty" if its length is a factor of the next largest unit.
    pretty intervals of seconds are 1,2,5,10,15,30 and 60 seconds
    pretty intervals of minutes are 1,2,5,10,15,30 and 60 minutes
    pretty intervals of hours are 1,2,3,4,6,8,12, and 24 hours
    pretty intervals of months are 1,2,3,4,6, and 12 months
    years and days adopt the base::pretty numbering system - 1,2, or 5 times a power of 10
    weeks are always ugly, and hence not included
  3. chooses the closest start and end points that are a) outside the range of data, and b) begin a series whose points will overlap with the start of the next complete hour, month, year (i.e. whatever the next largest unit is).

@hadley
Copy link
Member Author

hadley commented Jul 27, 2009

Sounds perfect!

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants