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

Bug sometimes with polygon geoms, filtered factors, drop = FALSE, and width = NULL #5396

Closed
davidhodge931 opened this issue Aug 23, 2023 · 1 comment · Fixed by #5402
Closed
Labels
bug an unexpected problem or unintended behavior layers 📈

Comments

@davidhodge931
Copy link

Bugs only sometimes with polygon geoms, filtered factors, and drop = FALSE.

Always is fixed when width is not NULL.

Using ggplot2 3.4.3 (and also tested in 3.4.2)

library(tidyverse)

#filtered dataset
d <- diamonds |>
  filter(color %in% c("D", "H")) |>
  filter(cut %in% c("Ideal", "Good")) |>
  filter(clarity %in% c("VS1", "VS2"))

#example A
#doesn't works
d |>
  count(cut) |>
  ggplot() +
  geom_col(aes(x = n, y = cut)) +
  scale_y_discrete(drop = FALSE)

#works
d |>
  count(cut) |>
  ggplot() +
  geom_col(aes(x = n, y = cut), width = 0.9) +
  scale_y_discrete(drop = FALSE)

#works
d |>
  count(cut) |>
  ggplot() +
  geom_point(aes(x = n, y = cut)) +
  scale_y_discrete(drop = FALSE)

#doesn't work
d |>
  ggplot() +
  geom_violin(aes(x = price, y = cut)) +
  scale_y_discrete(drop = FALSE)

#works
d |>
  ggplot() +
  geom_violin(aes(x = price, y = cut), width = 0.9) +
  scale_y_discrete(drop = FALSE)

#example B
#doesn't works
d |>
  count(color) |>
  ggplot() +
  geom_col(aes(x = n, y = color)) +
  scale_y_discrete(drop = FALSE)

#example C
#works
d |>
  count(clarity) |>
  ggplot() +
  geom_col(aes(x = n, y = clarity)) +
  scale_y_discrete(drop = FALSE)

Created on 2023-08-23 with reprex v2.0.2

@davidhodge931 davidhodge931 changed the title Bug _sometimes_ with polygon geoms, filtered factors, drop = FALSE, and width = NULL Bug sometimes with polygon geoms, filtered factors, drop = FALSE, and width = NULL Aug 23, 2023
@teunbrand
Copy link
Collaborator

Some of these seem to already work in the development version of ggplot2. Only the violin case seems broken at the moment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior layers 📈
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants