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

Give midpoint argument to gradient scales #5824

Closed
wants to merge 6 commits into from

Conversation

teunbrand
Copy link
Collaborator

This PR aims to fix #3738.

In short, it adds a midpoint argument to scale_{fill/colour}_gradientn() and scale_{fill/colour}_stepsn() functions.

The approach somewhat diverges from the gradient2/steps2 variant, which will not accept rescaler arguments. The gradientn/stepsn variants will accept a rescaler, but it overrides any midpoint setting.

Reprex:

devtools::load_all("~/packages/ggplot2")
#> ℹ Loading ggplot2

p <- ggplot(mpg, aes(displ, hwy, colour = cty)) + geom_point()

p + scale_colour_gradientn(
  colours = c("purple", "white", "green"),
  midpoint = 15
)

p + scale_colour_stepsn(
  colours = c("purple", "white", "green"),
  midpoint = 15
)

Created on 2024-04-03 with reprex v2.1.0

@teunbrand
Copy link
Collaborator Author

Close this, replace by midpoint rescaler example

@teunbrand
Copy link
Collaborator Author

Closing this in favour of #5896

@teunbrand teunbrand closed this May 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature request: midpoint argument in scale_color_gradientn()
1 participant