Skip to contents

Create box plots with optional jittered points and statistical annotations using Insper's visual identity.

Usage

insper_boxplot(
  data,
  x,
  y,
  fill = NULL,
  palette = "categorical",
  add_jitter = NULL,
  add_notch = FALSE,
  box_alpha = 0.8,
  ...
)

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 = "lightblue")

  • NULL (default) to use default Insper teal

palette

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

add_jitter

Logical. If TRUE, adds jittered points. If NULL (default), automatically enables jitter when the largest group has <100 observations.

add_notch

Logical. If TRUE, creates notched boxplot. Default is FALSE

box_alpha

Numeric. Transparency of boxes (0-1). Default is 0.8

...

Additional arguments passed to ggplot2::geom_boxplot()

Value

A ggplot2 object

Examples

if (FALSE) { # has_insper_fonts()
# Simple boxplot with default fill
insper_boxplot(iris, x = Species, y = Sepal.Length)

# Static fill color
insper_boxplot(iris, x = Species, y = Sepal.Length, fill = "#F15A22")

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

# Boxplot without jitter
insper_boxplot(iris, x = Species, y = Sepal.Length, add_jitter = FALSE)
}