Skip to content

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

Closed
@teunbrand

Description

@teunbrand

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions