Skip to content

Improve color scale documentation #4450

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

Merged
merged 4 commits into from
Apr 28, 2021

Conversation

clauswilke
Copy link
Member

Improve color scale documentation. Closes #4415.

@clauswilke clauswilke requested a review from thomasp85 April 26, 2021 16:36
@clauswilke clauswilke added this to the ggplot2 3.3.4 milestone Apr 26, 2021
R/scale-colour.r Outdated
#' [scale_fill_gradient()]). Note that both continuous and binned scales
#' are configured with the same options values. In other words,
#' the option `ggplot2.continuous.colour` controls the behavior of both
#' `scale_colour_continuous()` and `scale_colour_binned()`. To manually set
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be more correct to say that the binned scale falls back to ggplot2.continuous.colour if ggplot2.binned.colour is not set?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yes, for some reason I missed this.

@clauswilke
Copy link
Member Author

@thomasp85 I have fixed the issue you pointed out and generally expanded the documentation of scale_colour_continuous() and related scales.

@thomasp85
Copy link
Member

This is kind of orthogonal to this PR, so sorry for hijacking it, but it occurs to me that the fallback to ggplot2.continuous.colour only should happen if that value is not a scale... you set ggplot2.continuous.colour to e.g. scale_colour_distiller() it would inadvertently transform scale_colour_binned() to a continuous scale

@clauswilke
Copy link
Member Author

I agree with your comment, but that's a lot of logic for a default argument. Should I move that logic into the main body of the function? I don't like complex code execution in default arguments anyways.

@thomasp85
Copy link
Member

I think it is already way too much to have in the signature so it is better moved inside the function...

But we should do this consistently then, maybe in a new PR

@clauswilke
Copy link
Member Author

That’s fine, I can do it. Can we merge this PR first?

Copy link
Member

@thomasp85 thomasp85 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, let us just merge this in

@clauswilke clauswilke merged commit cc3951c into tidyverse:master Apr 28, 2021
@clauswilke clauswilke deleted the issue-4415-color-scales branch April 28, 2021 15:26
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.

Binned scales with manual color choices
2 participants