sankey {PantaRhei}R Documentation

Plots a Sankey diagram

Description

Plots a Sankey diagram

Usage

sankey(
  nodes,
  flows,
  palette,
  node_style = list(),
  title = NULL,
  legend = FALSE,
  page_margin = 0.1,
  max_width = 0.2,
  rmin = 0.2,
  copyright = NULL,
  grill = NULL,
  verbose = FALSE
)

Arguments

nodes

data.frame, containing the nodes definition

flows

data.frame, containing the nodes definition

palette

data.frame, containing the nodes definition

node_style

list: containing node style specifiers:

type

Character: Node type; possible values are "box", "bar" and "arrow".

length

numeric: node length, as fraction plot size (default: 0.1).

gp

an object of class gpar, typically the output from a call to the function gpar(). This is basically a list of graphical parameter settings, describing the colors etc of the node.

label_pos

character: label position. values: auto, above, below, left, right, none.

label_anchor

character: label position (overrides label_pos). Values are NW, N, NE, W, E, SW, S, SE.

label_align

character: label alignment with respect to label_anchor. Values are NW, N, etc.

label_gp

an object of class gpar, describing the font and color of the label text.

mag_pos

similar to label_pos, but controls location of the node magnitude. Value inside plots the node magnitude inside the node. Value label plots the node magnitude beneath the node label.

mag_anchor

similar to label_anchor.

mag_align

similar to label_align.

mag_gp

similar to label_gp.

mag_fmt

character: format string for the node magnitude. default: "%.1f". see ?sprintf for more information.

title

character: plot title. use strformat() to specify formatting.

legend

logical or gpar: Specifies the plotting of a legend. valid values are NULL (default; no legend), TRUE (plot a legend using standard text size and color), or the output of a call to gpar(), to control legend text size and color.

page_margin

numeric: Page margin. Either a scalar, an (x,y) vector or an (left,bot,rt,top) vector

max_width

numeric: Maximum width of the flow bundles, in fraction of the plot size

rmin

numeric: Minimum radius for flow path bends (as fraction of the diagram's units)

copyright

character: optional copyright statement?

grill

logical: Plot a coordinate grill?

verbose

logical: print some diagnostic messages?

Value

The modified nodes data.frame

Examples

nodes <- data.frame(ID=c("A","B"), x=1:2, y=0)
flows <- data.frame(from="A", to="B", quantity=10, substance="stuff")
sankey(nodes, flows)

colors <- data.frame(substance="stuff", color="blue")
sankey(nodes, flows, colors)

sankey(nodes, flows, legend=TRUE)                       # Plots default legend
sankey(nodes, flows, legend=grid::gpar(fontsize=18, ncols=2)) # Large fonts; 2 columns

[Package PantaRhei version 0.1.2 Index]