Skip to content

Should discrete scales be expanded from the continuous range? #5582

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

Closed
teunbrand opened this issue Dec 14, 2023 · 1 comment
Closed

Should discrete scales be expanded from the continuous range? #5582

teunbrand opened this issue Dec 14, 2023 · 1 comment
Labels
visual change 👩‍🎨 Rendering change that will affect look of output

Comments

@teunbrand
Copy link
Collaborator

In the plot below, there are 2 things that are somewhat bothersome:

  1. The geom_vline() doesn't show up if I leave out geom_segment(), due to the fact that xintercept is a valid aesthetic for a continuous scale, but not a discrete scale.
  2. The geom_vline() is right at the edge of the panel, because the discrete limits are expanded from the discrete range, not the continuous range.

The first thing is due to #3342, which I think might be worth fixing at some point. The second thing is the purpose of this issue. Should we change the limit expansion so that discrete scales are expanded from their continuous limits?

library(ggplot2)

ggplot() +
  geom_col(aes(x = "foo", y = 2)) +
  geom_segment(aes(x = 0, xend = 2, y = 1, yend = 1)) +
  geom_vline(xintercept = c(0, 2), colour = "red")

Created on 2023-12-14 with reprex v2.0.2

@teunbrand teunbrand added the visual change 👩‍🎨 Rendering change that will affect look of output label Dec 14, 2023
@teunbrand
Copy link
Collaborator Author

I no longer think we should do this. It would change a bunch of cases where the width of a boxplot/bar/violin is included in the expansion calculation and it doesn't look quite right.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
visual change 👩‍🎨 Rendering change that will affect look of output
Projects
None yet
Development

No branches or pull requests

1 participant