-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Scale_*_viridis_b not using full width of palette #4372
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
Did you mean |
@yutannihilation yes, thanks, fixed it (I started with an example with 7 breaks, but changed to 4 to make it simpler) |
It's not that the values are binned and then mapped to a discrete palette; the palette is still continuous and trained by the original values. library(ggplot2)
library(patchwork)
range(diamonds$depth)
#> [1] 43 79
# a similar range of values
d <- data.frame(x = 40:80, y = 1)
p <- ggplot(d) +
geom_col(aes(x, y, fill = x))
p1 <- p + scale_fill_viridis_c(breaks = 4:7 * 10 + 5)
p2 <- p + scale_fill_viridis_b(n.breaks = 4)
p1 / p2 Created on 2021-03-17 by the reprex package (v1.0.0) |
@yutannihilation thanks for looking into it. I'm not sure I understand the cases where this is the better behavior. |
I think I'm with @gregleleu here and I would propose reopening the issue. I understand how the color scale gets mapped to the data values currently, and I agree it's a reasonable way of doing it, but stretching the entire range of color values over the existing bins such that the endpoints align would be similarly reasonable. There could be an option in |
Okay, then let's reopen. I have no strong opinion here. |
Hi there. Is there any progress? I totally agree with @gregleleu and @clauswilke, it would be nice if the full range can be used in the binned version of color maps! |
@modche the fantastic thing about open source development is that everybody can pitch in with pull requests! |
Added a PR to resolve this, adding a parameter to scale_*_viridis_b functions to switch the palette between gradient_n_pal and binned_pal. |
Thanks, @gregleleu, for your efforts. And, yes, @heike, a PR is certainly a good way to proceed here... I just was not able to figure out how to do this in this case. But, now, we have a suggestion. Would be nice to use the brilliant yellow from |
When using scale_(fill/colour)_viridis_b, the colors don't go all the way to the end of the palette, i.e. very-yellow yellow).
Is it intended to do that? How to change this behavior if it is?
Full palette (4 steps)

The text was updated successfully, but these errors were encountered: