-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Feature request: could colouring of date, datetime and time variables be supported more completely? #4982
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
Comments
For the continuous colour palettes, you can get pretty far with library(ggplot2)
ggplot(economics, aes(date, unemploy)) +
geom_line(aes(colour = date)) +
scale_colour_gradientn(
colours = rainbow(10),
trans = "date",
breaks = scales::breaks_width("10 years")
) df <- data.frame(
x = Sys.time() + seq(0, 2e6, length.out = 20),
y = rnorm(20)
)
ggplot(df, aes(x, y)) +
geom_line(aes(colour = x)) +
scale_colour_viridis_c(
trans = "time",
breaks = scales::breaks_width("5 days")
) Created on 2022-12-09 by the reprex package (v2.0.1) The binned version of scales have separate issues, because binning arithmetic is currently incompatible with dates. |
Thanks @teunbrand. I was not aware that you could do this. Yes, that would allow you to do most things other than apply another trans to the date or time colour variable |
Due to #5103 having been merged, I think there are now a sufficient amount of options to use date/time variables in non-position scales. Therefore, I'll thank you for this suggestion and hope you have enough tools to make this work. |
At present, there are only scale_colour_date and scale_colour_datetime functions available for modifying date, datetime and time colours. These appear to be equivalent to
scale_colour_gradient
.This means that it is not possible to create colour steps with date, datetime or time variables.
Not is it possible to use the methods and colours/values arguments of the scale_colour_gradientn function.
It would be awesome if date, datetime and time colouring were supported more completely in this way!
The text was updated successfully, but these errors were encountered: