-
Notifications
You must be signed in to change notification settings - Fork 2.1k
breaks = NULL drops axis altogether #2983
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
Comments
I have not looked at the code (note to self: look at the code), but could this be related to this other case of the missing axis? |
No, it‘s two separate issues. The other issue is simply caused by the discrete scale only placing breaks at discrete values found in the data, which is correct behavior I think. |
Thanks for the feedback Claus. So I think I've got something. Please let me know what you think. The first argument of the The code copied below makes it clear why
Now, two things. How to fix this issue such that Line 7 of 2363611#diff-348ffaa265a58dc2db9470750b00523bL7 Hadley changed
Above I bypass returning As a side comment, while exploring the code I noticed that a
While I use Here the only example I have tested:
|
What do we mean when we set breaks to NULL? It seems to me that setting As I recall it and as illustrated by various stackoverflow discussions, the old behaviour was to remove tick marks and labels, but not the line. See e.g. this question from 2010 (ancient history): https://stackoverflow.com/questions/2678141/. Remark: There is one example from the current PDF manual that gives a clear indication that setting Moreover, it seems to me that the usage of Suggestion 1: replace the default Suggestion 2: change the default behaviour of Any opinion? library(ggplot2)
theme_set(theme_classic()). # to show the axes, if any
# Set breaks = NULL inside scale_y_continuous, current behaviour: one example in the PDF documentation:
# From manual page 67, Examples of geom_dotplot
# y axis isn't really meaningful, so hide it
ggplot(mtcars, aes(x = mpg)) + geom_dotplot(binwidth = 1.5) +
scale_y_continuous(NULL, breaks = NULL)
# In stat_bin(), the default is "breaks = NULL"
# Default
ggplot(mtcars, aes(x = mpg)) + stat_bin()
# Set breaks = NULL: does not suppress axis, neither does it suppress labels
ggplot(mtcars, aes(x = mpg)) + stat_bin(breaks = NULL)
# Set breaks = NA: seems like NA ought to be a workable alternative to NULL
ggplot(mtcars, aes(x = mpg)) + stat_bin(breaks = NA)
#> Error: <text>:3:27: unexpected symbol
#> 2: library(ggplot2)
#> 3: theme_set(theme_classic()).
#> ^ Created on 2018-11-21 by the reprex package (v0.2.0). |
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/ |
Uh oh!
There was an error while loading. Please reload this page.
Setting
breaks = NULL
, to remove axis tick marks and labels, results in the axis being dropped altogether. I don't remember seeing this before. Is this an intended feature?Created on 2018-11-07 by the reprex package (v0.2.0).
The text was updated successfully, but these errors were encountered: