Skip to content

Remove warning when guide functions are used in identity scales #3131

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 2 commits into from
Feb 12, 2019

Conversation

clauswilke
Copy link
Member

This PR closes #3127 by adding a proper check for the presence or absence of a guide in the identity scales.

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

d <- base::data.frame(
  week = seq(1, 52, 1), 
  revenue = round(runif(52, 0, 100))
)

# discrete identity scale
ggplot(data = d, aes(x = week, y = revenue, fill = 'lightskyblue')) + 
  geom_col() + 
  scale_fill_identity(guide = guide_legend())

# continuous identity scale
ggplot(data = d, aes(x = week, y = 1, size = revenue/20)) + 
  geom_point() + 
  scale_size_identity(guide = guide_legend())

Created on 2019-02-11 by the reprex package (v0.2.1)

@clauswilke clauswilke requested a review from thomasp85 February 11, 2019 20:19
@@ -146,7 +146,7 @@ ScaleDiscreteIdentity <- ggproto("ScaleDiscreteIdentity", ScaleDiscrete,

train = function(self, x) {
# do nothing if no guide, otherwise train so we know what breaks to use
if (self$guide == "none") return()
if (isTRUE(self$guide == "none")) return()
Copy link
Member

Choose a reason for hiding this comment

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

I prefer identical(self$guide, "none") in this case.

Copy link
Member Author

Choose a reason for hiding this comment

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

thanks, fixed.

@clauswilke clauswilke merged commit 43dcd63 into tidyverse:master Feb 12, 2019
@clauswilke clauswilke deleted the issue-3127-identity-scale-guide branch February 12, 2019 21:06
@lock
Copy link

lock bot commented Aug 11, 2019

This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/

@lock lock bot locked and limited conversation to collaborators Aug 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Warning message when adding a manual scale in ggplot
3 participants