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

Feature Request: Minor breaks for discrete position scales #5434

Open
teunbrand opened this issue Sep 22, 2023 · 0 comments · May be fixed by #5777
Open

Feature Request: Minor breaks for discrete position scales #5434

teunbrand opened this issue Sep 22, 2023 · 0 comments · May be fixed by #5777
Labels
feature a feature request or enhancement scales 🐍

Comments

@teunbrand
Copy link
Collaborator

In discrete scales, the breaks are centered on groups, which can sometimes make it difficult to visually discern where groups start and end. To add more visual cues about this, I think it is a good idea to add a minor.breaks argument to discrete position scales, that subsequently puts minor panel grid lines at those positions. I also thinks it may pair well with #5287. Essentially, I'd like to have the following visual:

library(ggplot2)
#> Warning: package 'ggplot2' was built under R version 4.3.1

ggplot(mpg, aes(class, fill = factor(cyl))) +
  geom_bar(position = position_dodge(preserve = "single")) +
  annotate(
    "segment",
    x = 1.5:6.5, xend = 1.5:6.5,
    y = -Inf, yend = Inf,
    colour = 'white'
  ) +
  theme(panel.grid.major = element_blank())

But with this syntax:

ggplot(mpg, aes(class, fill = factor(cyl))) +
  geom_bar(position = position_dodge(preserve = "single")) +
  scale_x_discrete(minor.breaks = 1.5:6.5) +
  theme(panel.grid.major = element_blank())

Created on 2023-09-22 with reprex v2.0.2

@teunbrand teunbrand added guides 📏 feature a feature request or enhancement scales 🐍 and removed guides 📏 labels Oct 13, 2023
@teunbrand teunbrand linked a pull request Mar 15, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement scales 🐍
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant