Skip to content

Allow dup_axis within scale_x_date #2244

Closed

Description

@brianwdavis

A question on SO led to wondering why duplicate axes aren't usable with scale_x_date or *_datetime. I worked up fairly hacky solutions by converting to numerics and working back from date_breaks, but it should "just work". While you're at it, I'm sure it would be nice to be able to have transformed sec_axis: e.g. hours on the x-bottom and days on the x-top.

See reprexes at: https://stackoverflow.com/a/45373735/3330437

example desired

Activity

  1. added
    feature
    on Aug 21, 2017
  2. hadley commented on Oct 30, 2017

    @hadley
    Member

    @thomasp85 any chance you have time to take a look?

  3. thomasp85 commented on Oct 30, 2017

    @thomasp85
    Member

    When do you expect the next release? I can’t promise anything this week

  4. hadley commented on Oct 30, 2017

    @hadley
    Member

    I'll probably start the release process in 2-3 weeks.

  5. self-assigned this
    on Oct 30, 2017
  6. thomasp85 commented on Oct 30, 2017

    @thomasp85
    Member

    I'll give it a shot

  7. thomasp85 commented on Nov 8, 2017

    @thomasp85
    Member

    Do you have any feelings regarding the transformations allowed with dual axis in the current implementation? To me it seems dual date axes is mostly for decorative purposes, though someone might conceivably want to plot a timeserie with both Chinese and Gregorian calendar..?

  8. hadley commented on Nov 8, 2017

    @hadley
    Member

    Yeah, it's not clear that this needs to support transformation, but maybe just different breaks/labels? (i.e. have years on top and months on bottom)

  9. thomasp85 commented on Nov 8, 2017

    @thomasp85
    Member

    That’s my feeling too, but is also the solution resulting in the worst API. It would require an additional set of sec_axis/dup_axis functions that blocks the transformation argument..?

  10. hadley commented on Nov 8, 2017

    @hadley
    Member

    Hmmm, but it probably needs a different sec_axis anyway for date_breaks() etc?

  11. thomasp85 commented on Nov 17, 2017

    @thomasp85
    Member

    I suggest we postpone it to after this release. I’m still interested in doing it but I don’t want to butcher the API to get it done, so I’ll need some time to think it through...

  12. hadley commented on Nov 17, 2017

    @hadley
    Member

    Ok, np.

  13. kevinwolz commented on Nov 20, 2017

    @kevinwolz

    Another feature related to this is the ability to use two different columns/datasets from which to base the time axes. For example, I have a dataset with "actual time", which I would like to have label the bottom x-axis in date format, and "time since event", which I would like to have label the top x-axis in hours format.

    This would be very useful for me, but I also have a feeling that it would be useful in many time series analyses. Not sure what the best approach would be to accomplish this, though.

  14. thomasp85 commented on Nov 20, 2017

    @thomasp85
    Member

    My feeling is that this is a simple transformation, and an argument for keeping the transformation argument in the Datetime implementation

  15. ldecicco-USGS commented on Nov 22, 2017

    @ldecicco-USGS

    I just need axis ticks on the top axis of my timeseries graphs:

    ggplot(data = data.frame(date = seq.Date(from = as.Date("2010-01-01"),
                                              to = as.Date("2010-12-01"),
                                              length.out = 12),
                              y = 1:12)) +
      geom_point(aes(date, y)) +
      scale_y_continuous(sec.axis = dup_axis(labels = NULL)) +
      scale_x_continuous(sec.axis = dup_axis(labels = NULL))

    That will make my life soooo much easier

  16. thomasp85 commented on Nov 22, 2017

    @thomasp85
    Member

    The road to hell is, unfortunately, paved with good intentions. While it would be easy to support your use case we might inadvertently end up with an api that cannot easily grow or be maintained. Thus, we/I will need some time to think about how to best implement this it.

    Your needs have been noted though🙂

  17. ldecicco-USGS commented on Nov 22, 2017

    @ldecicco-USGS

    "Your needs have been noted though" - that's all I was going for. Thanks so much!

  18. added a commit that references this issue on Sep 18, 2018
    4b880bb
  19. lock commented on Mar 17, 2019

    @lock

    This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/

  20. locked and limited conversation to collaborators on Mar 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

featurescales 🐍

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions