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

More configurable continuous colorscale defaults #3827

Closed
cpsievert opened this issue Feb 20, 2020 · 2 comments
Closed

More configurable continuous colorscale defaults #3827

cpsievert opened this issue Feb 20, 2020 · 2 comments

Comments

@cpsievert
Copy link
Contributor

cpsievert commented Feb 20, 2020

scale_[fill/colour]_[continuous/binned] have a type argument which provides an entrypoint for customizing the scale's default. Currently, type only supports gradient and viridis. It seems reasonable that it could also support an arbitrary function, which would make the default much more configurable. For example:

library(ggplot2)
scale_colour_custom <- function(...) {
  scale_colour_gradient(..., low = "white", high = "green")
}
options(ggplot2.continuous.colour = scale_colour_custom)
qplot(1:10, 1:10, color = 1:10)

image

@cpsievert
Copy link
Contributor Author

cpsievert commented May 19, 2020

Done in #3828

@fcecinati
Copy link

fcecinati commented Apr 1, 2021

The issue has been closed, but the example above is still not working with the provided syntax in my session (R4.0 ggplot2 3.3.1), returning the followign error:

> library(ggplot2)
> scale_colour_custom <- function(...) {
+   scale_colour_gradient(..., low = "white", high = "green")
+ }
> options(ggplot2.continuous.colour = scale_colour_custom)
> qplot(1:10, 1:10, color = 1:10)
Error in switch(type, gradient = scale_colour_gradient(...), viridis = scale_colour_viridis_c(...),  : 
  EXPR must be a length 1 vector

If a different syntax is needed, could you please provide an example?

Screenshot of my sessionInfo()
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants