library(palmerpenguins)
## Warning: package 'palmerpenguins' was built under R version 4.4.1
library(ggdist)
theme_set(theme_bw(16))
#packageVersion("ggdist")
penguins %>%
  ggplot(aes(x=flipper_length_mm, y=species, fill=species))+
  stat_slab(aes(thickness = stat(pdf*n)),
                scale = 0.7) 
## Warning: `stat(pdf * n)` was deprecated in ggplot2 3.4.0.
## i Please use `after_stat(pdf * n)` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
## Warning: Removed 2 rows containing missing values or values outside the scale range
## (`stat_slabinterval()`).

#ggsave("ggdist_raincloud_plot.png")
penguins %>%
  ggplot(aes(x=flipper_length_mm, y=species, fill=species))+
  stat_slab(aes(thickness = stat(pdf*n)), 
                scale = 0.7) +
  stat_dotsinterval(side = "bottom", 
                    scale = 0.7, 
                    slab_size = NA) 
## Warning: Removed 2 rows containing missing values or values outside the scale range
## (`stat_slabinterval()`).
## Removed 2 rows containing missing values or values outside the scale range
## (`stat_slabinterval()`).

# ggsave("ggdist_raincloud_plot_with_summary_interval.png")
penguins %>%
  ggplot(aes(x=flipper_length_mm, y=species, fill=species))+
  stat_slab(aes(thickness = stat(pdf*n)), 
                scale = 0.7) +
  stat_dotsinterval(side = "bottom",
                    scale = 0.7,
                    slab_size = NA) + 
  scale_fill_brewer(palette = "Set2") +
  theme(legend.position = "none")+
  labs(title="Raincloud plot with ggdist")
## Warning: Removed 2 rows containing missing values or values outside the scale range
## (`stat_slabinterval()`).
## Removed 2 rows containing missing values or values outside the scale range
## (`stat_slabinterval()`).

# ggsave("ggdist_raincloud_plot_with_datapoints_as_drops.png")