-
Notifications
You must be signed in to change notification settings - Fork 31
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
Feature request: Vary colour/fill along ridgeline #82
Comments
I'm not sure what exactly you're asking. There is |
It does almost - works for fill, but not for colour. I was using colour myself, and just assumed they would both be implemented in a similar way. So I guess the request is really about supporting varying colour. Currently, it raises the error:
Then in addition, it might be worth changing the error message of
|
The limitation of which aesthetics can vary come from the R graphics device. There's little I can do. And I don't want to encourage people to use the gradient versions of the geoms because I'm uncomfortable with how the effect is achieved. It's a bad workaround. If at some point the R graphics device can vary color and/or size along a line then we can consider this feature. |
That's of course up to you. I think it would be useful now that it is implemented anyways. I'm not sure about whether it's not possible to vary colour along a line. This example works just fine:
Is there an underlying limitation you're thinking of? EDIT: Ah, because the Y axis is essentially categorical in the ridgelines? But I guess if |
The code in your latest example doesn't run for me. Please use the reprex package to provide examples: https://reprex.tidyverse.org/articles/magic-reprex.html |
Ah, sorry, here you go: library(ggridges)
library(lubridate)
#> Loading required package: timechange
#>
#> Attaching package: 'lubridate'
#> The following objects are masked from 'package:base':
#>
#> date, intersect, setdiff, union
library(tidyverse)
lincoln_weather %>%
mutate(date = as_date(CST),
day_n = mday(date)) %>%
filter(as_date(date) < as_date("2017-01-01")) %>%
ggplot(aes(x = day_n, y = `Mean Temperature [F]`, colour = `Mean Temperature [F]`, group = Month)) +
geom_line() Created on 2023-01-09 with reprex v2.0.2 |
The thing is this may look fine if you're not looking carefully, but you're not actually getting continuous lines, you're getting individual line segments. This is both ugly and causes a headache for something like ggridges. I can't use the same rendering code I currently have and just change line color along the way. Increasing the line thickness demonstrates this clearly. library(tidyverse)
library(ggridges)
library(lubridate)
lincoln_weather %>%
mutate(date = as_date(CST),
day_n = mday(date)) %>%
filter(as_date(date) < as_date("2017-01-01")) %>%
ggplot(aes(x = day_n, y = `Mean Temperature [F]`, colour = `Mean Temperature [F]`, group = Month)) +
geom_line(linewidth = 5) Created on 2023-01-09 with reprex v2.0.2 |
Oh boy, I didn't know that! That's unfortunate, I guess I'll just have to find a way around it for now then... Do you know if changing this behaviour is on the core R teams radar? Or the Posit team? |
Hey Claus - thanks for some amazing work with
ggridges
!I'm using
geom_ridgeline
, and would like to be able to colour the line by a variable (e.g. the same as height). Although it's possible to colour the fill/colour using geom_density_ridges_gradient, it doesn't seem to be possible in other cases, e.g. for a time series.Here's a minimal example of what I'd like to be able to do:
The text was updated successfully, but these errors were encountered: