Skip to content

Fix the discrete scale when all values are continuous #3487

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

Conversation

yutannihilation
Copy link
Member

Fix #3463

After #3426, the following fails because scale$get_limits() returns NULL. This PR fixes this by reverting if branches to the previous code while the functional limits are still accepted.

library(ggplot2)

df <- data.frame(x = c(0, 2, 4), y = 1:3, stringsAsFactors = FALSE)

ggplot(df, aes(x, y)) +
  geom_point() +
  scale_x_discrete()
#> Warning in structure(in_domain, pos = match(in_domain, breaks)): Calling 'structure(NULL, *)' is deprecated, as NULL cannot have attributes.
#>   Consider 'structure(list(), *)' instead.

#> Warning in structure(in_domain, pos = match(in_domain, breaks)): Calling 'structure(NULL, *)' is deprecated, as NULL cannot have attributes.
#>   Consider 'structure(list(), *)' instead.
#> Error in UseMethod("rescale"): no applicable method for 'rescale' applied to an object of class "list"

Created on 2019-07-30 by the reprex package (v0.3.0)

(As this bug only exists in the dev version, no NEWS bullet is needed here)

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.

LGTM

@yutannihilation
Copy link
Member Author

Thanks!

@yutannihilation yutannihilation merged commit 18c540e into tidyverse:master Aug 26, 2019
@yutannihilation yutannihilation deleted the fix/issue-3463-discrete-values branch August 26, 2019 11:18
@lock
Copy link

lock bot commented Feb 22, 2020

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 Feb 22, 2020
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.

Discrete scales cannot handle continuous values
2 participants