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

No warning in stat_ydensity when dropping groups #4111

Closed
andrewwbutler opened this issue Jul 1, 2020 · 1 comment
Closed

No warning in stat_ydensity when dropping groups #4111

andrewwbutler opened this issue Jul 1, 2020 · 1 comment

Comments

@andrewwbutler
Copy link
Contributor

Hi,

I noticed the following behavior in geom_violin when there are fewer than three data points in a given violin. In this scenario, one of the violins gets dropped without a warning.

library(ggplot2)
table(mtcars$cyl, mtcars$am)
#>    
#>      0  1
#>   4  3  8
#>   6  4  3
#>   8 12  2
ggplot(mtcars, aes(x = factor(cyl), y = mpg)) + 
  geom_violin(scale = "width", aes(fill = factor(am))) 

Created on 2020-07-01 by the reprex package (v0.3.0)

It seems a related issue was addressed in stat_density in #2142 . I would propose that stat_ydensity be updated similarly here

if (nrow(data) < 3) return(new_data_frame())
Happy to put together a small PR for this if people agree.

@clauswilke
Copy link
Member

That seems reasonable.

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

No branches or pull requests

2 participants