- R Data Visualization Recipes
- Vitor Bianchi Lanzetta
- 140字
- 2021-07-02 23:33:37
How it works...
First step simply draws the very basic aesthetics into an object called base, to be used by following steps. Step 2 draws a very simple violin plot, while next step introduces a useful argument and a possible combination.
In step 3, the fill argument is used to color the insides of the violins. Color 'steelblue1' is picked. Next, geom_boxplot() is stacked in order to draw boxes inside the violins. For this intent, it is very important to erase the outliers by setting outliers.shape = NA and reduce boxes' widths with the help of the width argument.
Drawing violin plots using ggplot2 is very simple. Yet more complexity can be called to sum up some extra information, and some useful tricks can be deployed to improve plots. The following recipes are taking care of it.