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

Datetime scales don't support out of bounds (oob) arguments #4199

Closed
teunbrand opened this issue Sep 11, 2020 · 1 comment · Fixed by #4229
Closed

Datetime scales don't support out of bounds (oob) arguments #4199

teunbrand opened this issue Sep 11, 2020 · 1 comment · Fixed by #4229

Comments

@teunbrand
Copy link
Collaborator

I've noticed that date/time scales do not support the oob argument that the continuous scales have, while I do think this might be a useful feature.

Let's say I have the following graph, of which I would want the x-axis labelling:

library(ggplot2)

ggplot(economics, aes(date, unemploy)) +
  geom_line() +
  scale_x_date(limits = as.Date(c("1970-01-01", "2010-01-01")))
#> Warning: Removed 93 row(s) containing missing values (geom_path).

But I'd like the line to look like the following:

ggplot(economics, aes(as.numeric(date), unemploy)) +
  geom_line() +
  scale_x_continuous(
    limits = as.numeric(as.Date(c("1970-01-01", "2010-01-01"))),
    oob = scales::oob_squish
  )

Created on 2020-09-11 by the reprex package (v0.3.0)

This does not currently seem possible. However, as the ggplot2:::datetime_scale() function passes the ... to continuous_scale() (which does use oob), it would seem most of the infrastructure for oob arguments is already there.

Thanks for considering!

@yutannihilation
Copy link
Member

This sounds good to me. Datetime scales lost ... on this commit 4870fb0#diff-053b14c802505a7a11aeffaefe971dd4R57, and there seems no intention. Would you mind creating a pull request for this?

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

Successfully merging a pull request may close this issue.

2 participants