Skip to contents

Create beeswarm plots showing individual data points arranged to avoid overlap while reflecting density. This is a convenience wrapper around BoxPlot() with add_beeswarm = TRUE and add_point = TRUE.

Usage

BeeswarmPlot(data, ..., add_beeswarm = TRUE, add_point = TRUE)

Arguments

data

A data frame containing the data to plot

...

Additional arguments passed to atomic plotting functions.

add_beeswarm

Logical; use beeswarm layout instead of jitter for points. Requires the ggbeeswarm package. Not compatible with paired_by.

add_point

Logical; add jittered data points

Value

A ggplot object or combined plots (patchwork)

Examples

# \donttest{
set.seed(123)
data <- data.frame(
  group = rep(LETTERS[1:4], each = 25),
  value = c(
    rnorm(25, 10, 2), rnorm(25, 12, 2),
    rnorm(25, 11, 3), rnorm(25, 14, 2)
  )
)

# Basic beeswarm plot
BeeswarmPlot(data, x = "group", y = "value")


# With trend line
BeeswarmPlot(data, x = "group", y = "value", add_trend = TRUE)

# }