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

Allow Gradient Scales to Accept Midpoint Arg #136

Open
alex-gable opened this issue Dec 30, 2021 · 0 comments
Open

Allow Gradient Scales to Accept Midpoint Arg #136

alex-gable opened this issue Dec 30, 2021 · 0 comments

Comments

@alex-gable
Copy link

Instead of calling continuous_scale, scale_*_gradient_{theme} should call the appropriate ggplot2::scale_*_gradient function.

for example, ggplot::scale_fill_gradient2() includes the midpoint argument (and default), which it passes to continuous_scale()'s rescaler..

> scale_fill_gradient2
function (..., low = muted("red"), mid = "white", high = muted("blue"), 
    midpoint = 0, space = "Lab", na.value = "grey50", guide = "colourbar", 
    aesthetics = "fill") 
{
    continuous_scale(aesthetics, "gradient2", div_gradient_pal(low, 
        mid, high, space), na.value = na.value, guide = guide, 
        ..., rescaler = mid_rescaler(mid = midpoint))
}

this is very similar to - and possibly redundant with - what I see in scale_fill_gradient2_tableau()

> ggthemes::scale_fill_gradient2_tableau
function (palette = "Orange-Blue Diverging", ..., na.value = "grey50", 
    guide = "colourbar") 
{
    continuous_scale("fill", "tableau2", tableau_div_gradient_pal(palette), 
        na.value = na.value, guide = guide, ...)
}

while this same functionality could be implemented in manually, it seems to me to be more appropriate and intuitive that a function like scale_fill_gradient2_tableau would extend scale_fill_gradient2 which extends continuous_scale

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

No branches or pull requests

1 participant