Distribution plot 3
Category: distribution
library(tidyverse)
library(gghalves)
library(ggbeeswarm)
library(wesanderson)
# https://github.com/allisonhorst/palmerpenguins
library(palmerpenguins)
p <- ggplot(penguins, aes(species, culmen_depth_mm, fill = species)) +
geom_violin(draw_quantiles = c(0.25, 0.75), scale = 'count', trim = FALSE, linetype = 'dashed') +
geom_violin(draw_quantiles = 0.5, scale = 'count', trim = FALSE, fill = 'transparent') +
stat_summary(fun = mean, geom = 'point', size = 5, color = 'black') +
scale_color_manual(name = 'Species', values = wes_palette('Darjeeling1', 3, type = 'discrete')) +
scale_fill_manual(values = wes_palette('Darjeeling1', 3, type = 'discrete')) +
scale_y_continuous(labels = scales::comma) +
theme_bw() +
labs(y = 'Culmen depth [mm]') +
theme(
legend.position = 'none',
axis.title.x = element_blank(),
panel.grid.major.x = element_blank()
)
ggsave('4.png', p, height = 5, width = 6)