Creates violin plots with Insper's visual identity, with optional boxplot and jittered-point overlays.
Usage
insper_violin(
data,
x,
y,
fill = NULL,
palette = "main",
show_boxplot = FALSE,
show_points = FALSE,
violin_alpha = 0.7,
...
)Arguments
- data
A data frame.
- x
<
data-masked> Categorical variable for the x-axis.- y
<
data-masked> Numeric variable for the y-axis.- fill
Fill aesthetic. Accepts one of the options below.
A bare column name, mapped to fill (e.g.,
fill = Species).A quoted color string, used as a static fill (e.g.,
fill = "purple").NULL(default), which uses Insper turquesa.
- palette
Character. Palette for mapped variables. Default is
"main".- show_boxplot
Logical. If
TRUE, overlays a boxplot. Default isFALSE.- show_points
Logical. If
TRUE, adds jittered points. Default isFALSE.- violin_alpha
Numeric. Violin opacity, from 0 to 1. Default is 0.7.
- ...
Additional arguments passed to
ggplot2::geom_violin().
Examples
if (FALSE) { # has_insper_fonts()
# Simple violin plot with default fill
insper_violin(iris, x = Species, y = Sepal.Length)
# Static fill color
insper_violin(iris, x = Species, y = Sepal.Length, fill = "#E50505")
# Variable fill mapping
insper_violin(iris, x = Species, y = Sepal.Length, fill = Species)
# Another palette
insper_violin(iris, x = Species, y = Sepal.Length, fill = Species, palette = "muted")
# With boxplot overlay and points
insper_violin(iris, x = Species, y = Sepal.Length,
show_boxplot = TRUE, show_points = TRUE)
}
