|
2 | 2 |
|
3 | 3 | # A violin plot is a compact display of a continuous distribution. It is a mirrored density plot displayed in the same way as a boxplot. Violin plots are useful for comparing distributions across groups, as they show more detail about the shape of the distribution than boxplots while still being compact. |
4 | 4 |
|
| 5 | +# ## Note on apppropriate use |
| 6 | + |
| 7 | +# The violin plot is somewhat controversial and there is usually a better way to display your data. For a discussion of this topic, see [this video](https://www.youtube.com/watch?v=_0QMKFzW9fw) by Angela Collier. |
| 8 | + |
5 | 9 | # ## Arguments |
6 | 10 |
|
7 | 11 | # - `plot::GGPlot` (optional): a plot object to add this geom to. This is typically used to facilitate creating your ggplot as part of a @chain. |
@@ -84,26 +88,6 @@ ggplot(penguins, @aes(x = species, y = bill_length_mm)) + |
84 | 88 | ggplot(penguins, @aes(x = species, y = bill_length_mm, fill = species)) + |
85 | 89 | geom_violin(strokecolor = :black, strokewidth = 1) |
86 | 90 |
|
87 | | -# ## Combining with Other Geoms |
88 | | - |
89 | | -# Combine violin with boxplot for more information: |
90 | | - |
91 | | -ggplot(penguins, @aes(x = species, y = bill_length_mm)) + |
92 | | - geom_violin() + |
93 | | - geom_boxplot(width = 0.2, alpha = 0.8) |
94 | | - |
95 | | -# Add individual data points: |
96 | | - |
97 | | -ggplot(penguins, @aes(x = species, y = bill_length_mm)) + |
98 | | - geom_violin(alpha = 0.5) + |
99 | | - geom_point(alpha = 0.3) |
100 | | - |
101 | | -# Use jittered points for better visibility: |
102 | | - |
103 | | -ggplot(penguins, @aes(x = species, y = bill_length_mm)) + |
104 | | - geom_violin(strokecolor = :black) + |
105 | | - geom_jitter(alpha = 0.3, width = 0.1) |
106 | | - |
107 | 91 | # ## Comparing Multiple Variables |
108 | 92 |
|
109 | 93 | # Compare distributions across different measurements: |
|
0 commit comments