Skip to contents

Create violin plots to visualize distributions using Insper's visual identity. Optionally overlay boxplots and/or jittered points.

Usage

insper_violin(
  data,
  x,
  y,
  fill = NULL,
  palette = "categorical",
  show_boxplot = FALSE,
  show_points = FALSE,
  violin_alpha = 0.7,
  ...
)

Arguments

data

A data frame containing the data to plot

x

Variable for x-axis (categorical)

y

Variable for y-axis (numeric)

fill

Fill aesthetic. Accepts either:

  • A bare column name for variable mapping (e.g., fill = Species)

  • A quoted color string for static fill (e.g., fill = "purple")

  • NULL (default) to use default Insper teal

palette

Character. Color palette for variable mappings. Default is "categorical".

show_boxplot

Logical. If TRUE, overlays a boxplot. Default is FALSE

show_points

Logical. If TRUE, adds jittered points. Default is FALSE

violin_alpha

Numeric. Transparency of violins (0-1). Default is 0.7

...

Additional arguments passed to ggplot2::geom_violin()

Value

A ggplot2 object

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 = "#E4002B")

# Variable fill mapping
insper_violin(iris, x = Species, y = Sepal.Length, fill = Species)

# Custom palette
insper_violin(iris, x = Species, y = Sepal.Length, fill = Species, palette = "bright")

# With boxplot overlay and points
insper_violin(iris, x = Species, y = Sepal.Length,
              show_boxplot = TRUE, show_points = TRUE)
}