Skip to contents

Compare profiles on equally spaced spokes with common or per-axis scaling. Both long and wide inputs use the same coordinate calculation. The plot is a standard ggplot with fixed aspect ratio and ordinary Cartesian layers.

Usage

ggradar(
  data,
  axis = NULL,
  value = NULL,
  group = NULL,
  vars = NULL,
  limits = NULL,
  order = NULL,
  grid = c("polygon", "circle", "none"),
  start = 0,
  direction = 1,
  missing = c("error", "gap", "omit_group"),
  fill = TRUE,
  points = TRUE,
  facet = NULL,
  label = FALSE,
  reference = NULL,
  intervals = NULL
)

Arguments

data

A nonempty data frame with uniquely named columns.

axis, value

Long-format columns giving an axis ID and a numeric measurement. Supply bare names or single strings.

group

Optional profile column, as a bare name or single string. Supply one measurement per axis and profile. Each row of wide data is one profile.

vars

Wide-format numeric columns. Use an ordered c() of bare or quoted names, or all_of(column_names) with a character vector. Omit axis and value when using vars.

limits

Two finite, increasing numbers for one shared scale, or a data frame with axis, lower and upper columns for per-axis scales. In the table, give each axis ID exactly once. Bounds use the original units and must be finite, increasing and have a finite span. An optional breaks list-column supplies distinct, in-range tick values for each axis. Use NULL for default ticks or numeric(0) to omit an axis's ticks. When the entire limits argument is NULL, one range covers zero and all observed values. Supply explicit bounds when comparing separate figures.

order

Optional character vector with every observed axis ID exactly once. By default long input uses factor level order or first appearance. Wide input uses the selection order.

grid

Ring style. Choose "polygon", "circle", or "none".

start

Starting angle in radians measured clockwise from the top.

direction

Use 1 for clockwise or -1 for counterclockwise.

missing

How to handle NA or a missing axis row. Use "error", "gap" for open lines and points, or "omit_group" to drop incomplete profiles. Missing axes leave both incident edges open.

fill

Fill complete profiles with a translucent colour.

points

Draw points at observed values.

facet

Optional facet columns, selected like vars. Short profiles are resolved separately in each panel. Axis order, bounds and breaks are identical across all panels.

label

Display original values near the data vertices. Labels near the outer boundary are placed inward to leave room for axis names.

reference

Optional target values in original units. Supply a numeric vector named by axis ID, a data frame with axis and value, or one number when all axes share a scale. Targets appear as diamonds with a dashed outline where adjoining axes have targets.

intervals

Optional data frame with axis, lower and upper in original units. Supply one row per axis. Adjoining axes with both bounds form a shaded band. Use geom_radar_band() for intervals that vary by panel or series.

Value

A ggplot2::ggplot() object. Add titles, layers, scales and themes with ordinary ggplot2 grammar. Use equal x and y units to keep the shape.

Details

Supply a bounds table for measurements in different units. Each value is positioned by the fraction of its axis range above the lower bound. Out-of-range values, duplicated profile and axis pairs, and nonfinite values other than NA produce errors. Incomplete profiles are never filled. When points = FALSE, an isolated value in a gapped profile has no visible mark.

A closed shape's area depends on the spoke order and scale. Interpret values along their spokes. Use facet when subjects repeat across panels. The same reference and interval band repeat in each facet. Both use the data scale and must fit within its bounds. Supply explicit limits when overlays extend beyond the scale inferred from observations. The missing policy applies separately to each overlay. Supplied interval bounds describe individual indicators. The filled shape carries no joint coverage guarantee.

Examples

scores <- data.frame(site = c("A", "B"), detection = c(84, 66),
                     laboratory = c(63, 83), response = c(90, 62))
ggradar(scores, vars = c(detection, laboratory, response),
        group = site, limits = c(0, 100))


indicators <- data.frame(axis = c("Detection", "Lab", "Response"),
                         score = c(84, 63, 90))
ggradar(indicators, axis, score, limits = c(0, 100), grid = "circle")


measures <- data.frame(axis = c("Coverage (%)", "Tests", "Wait (days)"),
                       value = c(80, 600, 7))
ranges <- data.frame(axis = measures$axis, lower = c(0, 0, 2),
                     upper = c(100, 1200, 14))
ranges$breaks <- list(c(25, 50, 75), c(300, 600, 900), c(5, 8, 11))
ggradar(measures, axis, value, limits = ranges, label = TRUE)

band <- data.frame(axis = measures$axis, lower = c(60, 400, 5), upper = c(85, 900, 10))
ggradar(measures, axis, value, limits = ranges, intervals = band,
        reference = c("Coverage (%)" = 75, Tests = 800, "Wait (days)" = 8))