2.Violin plots
2.1 Basic violin plot
df$cyl <- as.factor(df$cyl)
head(df)## mpg cyl wt
## Mazda RX4 21.0 6 2.620
## Mazda RX4 Wag 21.0 6 2.875
## Datsun 710 22.8 4 2.320
## Hornet 4 Drive 21.4 6 3.215
## Hornet Sportabout 18.7 8 3.440
## Valiant 18.1 6 3.460ggplot(df, aes(x=cyl, y=mpg)) +
geom_violin(trim=FALSE) +
labs(title="Plot of mpg per cyl", x="Cyl", y = "Mpg")
2.2 Add summary statistics on a violin plot
2.2.1 Add median and quartile


2.2.2 Add mean and standard deviation


2.3 Change violin plot fill colors

Last updated