Open
Description
I found a problem with geom_bar(position="fill")
I expected the plot's y axis to have a proportion where it ranges from 0 to 1. However, when the color combinations produce single values, the count is provided, not the proportion of 100%.
Here is the code to reproduce the bug:
library(ggplot2)
# Good: Y axis is proportion
ggplot(mtcars, aes(factor(cyl), fill = factor(vs))) + geom_bar(position="fill")
ggplot(GGally::tips, aes(x = smoker, fill = sex)) + geom_bar(position = "fill")
# Bad: Y axis is count, not proportion
ggplot(subset(mtcars, cyl == 8), aes(factor(cyl), fill = factor(vs))) + geom_bar(position="fill")
ggplot(GGally::tips, aes(x = smoker, fill = smoker)) + geom_bar(position = "fill")
Created on 2025-06-19 with reprex v2.1.1
sessioninfo::package_info("ggplot2")
#> ggplot2 * 3.5.2.9001 2025-06-19 [1] Github (tidyverse/ggplot2@a2d0181)