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

Limits of binned scales when data has zero width #6225

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

teunbrand
Copy link
Collaborator

This PR aims to fix #5066.

Briefly, when the default limits of binned scales have zero-width, they are expanded to have 0.1 width (the same as default_expansion()).

Reprexes from the linked issue:

devtools::load_all("~/packages/ggplot2/")
#> ℹ Loading ggplot2

data.frame(x = c("a", "b"), 
           y = c("A", "B")) |> 
  ggplot() + 
  geom_bin_2d(aes(x = x, y = y)) + 
  scale_fill_binned()

ggplot(data.frame(x=1), aes(x=x)) + geom_bar() + scale_x_binned()

Created on 2024-12-10 with reprex v2.1.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

scale_fill_binned throws error if all bins have the same value
1 participant