Kapitel 69 ggplot Beispiele

69.1 Boxplot mit Strich auf den Whiskers

Dank geht an

set.seed(42)
df <- data.frame(cond = factor(rep(c("A", "B"), each = 500)), 
                 value = c(rnorm(500, mean = 1, sd = 0.2), 
                           rnorm(500, mean = 1.5, sd = 0.1))) 

library(ggplot2)

boxplot<-ggplot(df, aes(x = cond, y = value)) +
  stat_boxplot(geom = "errorbar", width = 0.05) +  
  geom_boxplot(width=0.3, fill=c("#DB66F2", "#430CF5"), alpha=0.6)
  
library(ggthemes) #  https://www.rdocumentation.org/packages/ggthemes/versions/3.5.0/topics/theme_stata
boxplot + theme_stata()