Boxplot with theme_void() in 4.0.0 gets a background
Closed this issue · 4 comments
I discovered the bug in daattali/ggExtra#182 and was sure it was my fault! But looks like it might not be? @thomasp85 I wasn't crazy :)
Run the following code in ggplot 3.5.1 and 4.0.0:
ggplot(mtcars, aes(x = factor(cyl), y = mpg)) +
geom_boxplot(alpha = 0.5) + theme_void()
These are the plots you get:

Thanks for the report! The new theme defaults populate boxplots with a completely transparent black fill in theme_void(). By setting alpha = 0.5, you're getting rid of the 'completely' part of that setting, which shows up as gray. I don't think it'd make sense for us to revert any of the ggplot2 4.0.0 changes or make special-case exceptions for this use case.
Only theme_void() seems to do that, most other themes don't. This is on purpose?
Yes, theme void has a transparent paper of whatever the ink colour is. By default, ink is black, so paper becomes transparent black (#00000000), whereas most other themes have simply paper = "white".
In any case, I'm not inclined into rolling back the change that causes this. If you want semi-transparent white fill, you can simply set fill = alpha("white", 0.5) instead of alpha = 0.5.