Skip to contents

Chord Diagram

Usage

geom_chord_diagram(
  mapping = NULL,
  data = NULL,
  gap_degree = 2,
  start_degree = 90,
  direction = 1,
  inner_radius = 0.6,
  outer_radius = 0.75,
  n_bezier = 100,
  show_labels = TRUE,
  arc_params = list(),
  sector_params = list(),
  label_params = list()
)

Arguments

mapping

A ggplot2::aes() mapping. Must supply at minimum source, target, and freq.

data

Data frame. If NULL, inherits from the plot.

gap_degree

Degrees of gap between sectors (default 2).

start_degree

Starting angle in degrees for the first sector (default 90).

direction

1 = counter-clockwise (default), -1 = clockwise.

inner_radius

Normalised inner radius of the sector ring (default 0.6).

outer_radius

Normalised outer radius of the sector ring (default 0.75).

n_bezier

Smoothness: number of points per curve (default 100).

show_labels

Logical. Draw node labels? Default TRUE.

arc_params

Named list of additional parameters passed to geom_chord_arcs.

sector_params

Named list of additional parameters passed to geom_chord_sectors.

label_params

Named list of additional parameters passed to geom_chord_labels.

Value

A list of ggplot2 layers

Aesthetics

geom_chord_diagram() understands the following aesthetics (required in **bold**):

  • source – name of the originating node

  • target – name of the receiving node

  • freq – numeric flow / weight

  • fill – fill colour of ribbons / sectors

  • colour – border colour

  • alpha – transparency (default 0.6 for ribbons, 1 for sectors)

  • linewidth – border line width

Examples

library(ggplot2)
flows <- data.frame(
  source = c("A", "A", "B", "B", "C", "C"),
  target = c("B", "C", "A", "C", "A", "B"),
  freq   = c(50, 30, 60, 25, 35, 20)
)
ggplot(
  data = flows,
  mapping = aes(
    source = source,
    target = target,
    freq = freq
  )
) +
  geom_chord_diagram()