You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
scale_x_discrete with numeric drops axis with no warning #2970
Discrete scales are not designed to work with numeric data, this is clear. However, a careless/naive user could attempt to apply a discrete scale to continuous data. I suggest issuing a warning when a discrete scale is applied to continuous data.
Use case: I absent-mindedly tried to apply scale_x_discrete to a continuous scale (the data was intended to be discrete, but was actually numeric) and discovered that the axis was dropped altogether and no warning issued. I hadn't noticed the problem until I used expand_scale inside the scale_x_discrete. Before that I was able to set limits inside scale_x_discrete without losing the axis, so alarm bells hadn't sounded. A warning would save time debugging and/or potentially avoid producing an incorrect plot.
changed the title [-]scale_x_discrete with numeric no warning + drops the axis[/-][+]scale_x_discrete with numeric drops axis with no warning[/+]on Nov 6, 2018
— so it would require extremely careful analysis to determine if this was always a false positive or is actually needed for existing plots in the wild. It's my sense that this analysis would be sufficiently time consuming as not to be worthwhile, given the payoff.
Activity
[-]scale_x_discrete with numeric no warning + drops the axis[/-][+]scale_x_discrete with numeric drops axis with no warning[/+]hadley commentedon Jun 18, 2019
This appears to be a deliberate choice:
ggplot2/R/scale-discrete-.r
Line 115 in 6c2fe76
lock commentedon Dec 15, 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/