a11y_ggplot2_line: Accessible line chart

View source: R/plots.R

a11y_ggplot2_lineR Documentation

Accessible line chart

Description

A minimal wrapper for a multi-line chart with accessibility features using ggplot2::ggplot2. Provides a high-contrast color palette, distinct marker shapes, and a minimal theme by default.

Usage

a11y_ggplot2_line(
  data,
  x,
  y,
  group = NULL,
  accessible_colors = NULL,
  marker_shapes = NULL,
  line_width = 1,
  marker_size = 2,
  legend_title = NULL,
  ...
)

Arguments

data

Data frame

x

Column name for the x-axis (unquoted)

y

Column name for the y-axis (unquoted)

group

(optional) Column name for grouping lines (unquoted)

accessible_colors

(optional) Character vector of colors for the palette

marker_shapes

(optional) Numeric vector of point shapes, e.g. c(16, 17, 15, 3, 7, 4, 10)

line_width

(optional) Line width (default: 1)

marker_size

(optional) Point size (default: 2)

legend_title

(optional) Title for the legend

...

Additional arguments passed to ggplot2::labs()

Value

A ggplot2::ggplot() object

Examples

# Simple line chart (no grouping)
df <- data.frame(year = 2020:2024, value = c(10, 14, 13, 17, 20))
a11y_ggplot2_line(
  data = df, x = year, y = value,
  title = "Trend"
)

# Grouped line chart
df2 <- data.frame(
  year  = rep(2020:2024, 2),
  value = c(10, 14, 13, 17, 20, 8, 9, 11, 12, 15),
  grp   = rep(c("A", "B"), each = 5)
)
a11y_ggplot2_line(
  data = df2, x = year, y = value,
  group = grp, title = "Trend by Group"
)

# With legend title and additional ggplot2 layers
p <- a11y_ggplot2_line(
  data = df2, x = year, y = value, group = grp,
  legend_title = "Group",
  title = "Trend by Group"
)
p + ggplot2::geom_hline(yintercept = 12, linetype = "dashed") +
  ggplot2::labs(
    x = "Year", y = "Value",
    subtitle = "With custom axis labels"
  )


a11yShiny documentation built on April 1, 2026, 5:07 p.m.