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

scale_[xy]_discrete() causes removal of breaks/labels #1589

Closed
gfiumara opened this issue Mar 22, 2016 · 2 comments
Closed

scale_[xy]_discrete() causes removal of breaks/labels #1589

gfiumara opened this issue Mar 22, 2016 · 2 comments
Assignees

Comments

@gfiumara
Copy link
Contributor

@gfiumara gfiumara commented Mar 22, 2016

Summary

Using scale_[xy]_discrete(), regardless of arguments, causes axis labels and breaks to disappear without warning.

Example

library(ggplot2)
xyDF <- data.frame(x = 1:10, y = 1:10)
ggplot(data = xyDF, mapping = aes(x = x, y = y)) +
    geom_line() +
    geom_point() +
    scale_x_discrete()

Expected results

Plot showing breaks and labels at 1:10 on the X axis.

ggplot2_101
Created with ggplot2 1.0.1, as I cannot reproduce with 2.1.0.

Actual results

Plot with no breaks or labels on the X axis (as if scale_x_discrete(labels = NULL, breaks = NULL) was added to the plot instead of the default waiver()).
ggplot2_2

Notes

  • Regression since ggplot2 1.0.1 (last major version I've been using) fb3931c.
  • Present in devtools and CRAN version as of 22 March 2016.
@gfiumara
Copy link
Contributor Author

@gfiumara gfiumara commented Mar 28, 2016

Appears to have broken in commit 89893c7 (#1542), confirmed by running sample with different devtools installs:

# Works
devtools::install_github("hadley/ggplot2", ref="fb3931c4e925272ddba607b81ada998df630bc10")

# Broken in subsequent commit
devtools::install_github("hadley/ggplot2", ref="89893c71ea575e198240e008ba2f42c9cbb7c6b7")
@thomasp85
Copy link
Member

@thomasp85 thomasp85 commented Aug 25, 2016

This is an by design, as conversion from continuous to discrete data is not well-defined. It is easy to end up with thousands of breaks so it is up to the user to either provide the breaks explicitly or convert their data to a discrete format

@thomasp85 thomasp85 closed this Aug 25, 2016
@hadley hadley removed the ready label Aug 25, 2016
@lock lock bot locked as resolved and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants