Raincloud plot is another interesting use of Violinplots are. Rain cloud plot is basically a combination of horizontal half violin plots with jittered data points. We will see step-by-step examples of how to make raincloud plot in this tutorial in R with ggplot2.

Since there is no special function available for half violinplot in ggplot2, we will rely on @drob’s gist containing a function to make half violinplot. Let us first load tidyverse and set the theme for making half violinplots.

1
2
library(tidyverse)
theme_set(theme_bw(16))
We have slightly modified (fixed a small typo as suggested by a comment in the gist) the function @drob wrote and have it available at datavizpyr.com’s github account.
1
source("https://raw.githubusercontent.com/datavizpyr/data/master/half_flat_violinplot.R")

We will use our favorite Penguin dataset to make rain cloud plots with half violin plots.
1
p2data <- "https://raw.githubusercontent.com/datavizpyr/data/master/palmer_penguin_species.tsv"

1
2
3
4
5
6
7
8
9
10
11
penguins_df <- read_tsv(p2data)
### Parsed with column specification:
### cols(
##   species = col_character(),
##   island = col_character(),
##   culmen_length_mm = col_double(),
##   culmen_depth_mm = col_double(),
##   flipper_length_mm = col_double(),
##   body_mass_g = col_double(),
##   sex = col_character()
### )

Horizontal Half Violin Plots

Let us first get started with horizontal half violin plots using geom_flat_violin() function.

#r #raincloud plot #ggplot2 #cloud

Rain Cloud Plots using Half Violin Plot with jittered data points
8.70 GEEK