| Title: | Sankey, Alluvial and Sankey Bump Plots |
|---|---|
| Description: | A package that makes it easy to implement sankey, alluvial and sankey bump plots in ggplot2. |
| Authors: | David Sjoberg |
| Maintainer: | David Sjoberg <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.0.99999 |
| Built: | 2026-05-27 07:03:46 UTC |
| Source: | https://github.com/davidsjoberg/ggsankey |
Creates an alluvial plot which visualize flows between nodes. Each observation needs to have a 'x' aesthetic as well as a 'next_x' column which declares where that observation should flow. Also each observation should have a 'node' and a 'next_node' aesthetic which provide information about which group in the y-direction.
geom_alluvial( mapping = NULL, data = NULL, position = "identity", na.rm = FALSE, show.legend = NA, space = 0, width = 0.1, smooth = 8, inherit.aes = TRUE, ... )geom_alluvial( mapping = NULL, data = NULL, position = "identity", na.rm = FALSE, show.legend = NA, space = 0, width = 0.1, smooth = 8, inherit.aes = TRUE, ... )
mapping |
provide you own mapping. both x and y need to be numeric. |
data |
provide you own data |
position |
change position |
na.rm |
remove missing values |
show.legend |
show legend in plot |
space |
space between nodes in the y-direction |
width |
width of nodes |
smooth |
how much smooth should the curve have? More means steeper curve. |
inherit.aes |
should the geom inherit aesthetics |
... |
other arguments to be passed to the geo |
ggplot layer
Creates centered labels or text in nodes of your alluvial plot. Needs to have the exact same aesthetics as the call to 'geom_alluvial' to work.
geom_alluvial_text( mapping = NULL, data = NULL, position = "identity", na.rm = FALSE, show.legend = NA, space = 0, width = 0.1, inherit.aes = TRUE, ... ) geom_alluvial_label( mapping = NULL, data = NULL, position = "identity", na.rm = FALSE, show.legend = NA, space = 0, width = 0.1, inherit.aes = TRUE, ... )geom_alluvial_text( mapping = NULL, data = NULL, position = "identity", na.rm = FALSE, show.legend = NA, space = 0, width = 0.1, inherit.aes = TRUE, ... ) geom_alluvial_label( mapping = NULL, data = NULL, position = "identity", na.rm = FALSE, show.legend = NA, space = 0, width = 0.1, inherit.aes = TRUE, ... )
mapping |
provide you own mapping. both x and y need to be numeric. |
data |
provide you own data |
position |
change position |
na.rm |
remove missing values |
show.legend |
show legend in plot |
space |
space between nodes in the y-direction |
width |
width of nodes |
inherit.aes |
should the geom inherit aesthetics |
... |
other arguments to be passed to the geo |
Other important arguments is; 'space' which proves the space between nodes in the y-direction; 'shift' which shifts nodes in the y-direction.
ggplot layer
Creates a sankey plot which visualize flows between nodes. Each observation needs to have a 'x' aesthetic as well as a 'next_x' column which declares where that observation should flow. Also each observation should have a 'node' and a 'next_node' aesthetic which provide information about which group in the y-direction. By default each row of the data frame is counted to calculate the size of flows. A manual flow value can be added with the 'value' aesthetic.
geom_sankey( mapping = NULL, data = NULL, position = "identity", na.rm = FALSE, show.legend = NA, space = NULL, type = "sankey", width = 0.1, smooth = 8, inherit.aes = TRUE, ... )geom_sankey( mapping = NULL, data = NULL, position = "identity", na.rm = FALSE, show.legend = NA, space = NULL, type = "sankey", width = 0.1, smooth = 8, inherit.aes = TRUE, ... )
mapping |
provide you own mapping. both x and y need to be numeric. |
data |
provide you own data |
position |
change position |
na.rm |
remove missing values |
show.legend |
show legend in plot |
space |
space between nodes in the y-direction |
type |
either 'sankey' or 'alluvial' |
width |
width of nodes |
smooth |
how much smooth should the curve have? More means steeper curve. |
inherit.aes |
should the geom inherit aesthetics |
... |
other arguments to be passed to the geom |
ggplot layer
geom_sankey understand the following aesthetics (required aesthetics are in bold):
- **x0** - **y0** - **a** - **b** - **angle** - m1 - m2 - color - fill - size - linetype - alpha - lineend
Creates an alluvial plot which visualize flows between nodes. Each observation needs to have a 'x' aesthetic as well as a 'next_x' column which declares where that observation should flow. Also each observation should have a 'node' and a 'next_node' aesthetic which provide information about which group in the y-direction.
geom_sankey_bump( mapping = NULL, data = NULL, position = "identity", na.rm = FALSE, show.legend = NA, smooth = 8, type = "sankey", inherit.aes = TRUE, ... )geom_sankey_bump( mapping = NULL, data = NULL, position = "identity", na.rm = FALSE, show.legend = NA, smooth = 8, type = "sankey", inherit.aes = TRUE, ... )
mapping |
provide you own mapping. both x and y need to be numeric. |
data |
provide you own data |
position |
change position |
na.rm |
remove missing values |
show.legend |
show legend in plot |
smooth |
how much smooth should the curve have? More means steeper curve. |
type |
either 'sankey' or 'alluvial' |
inherit.aes |
should the geom inherit aesthetics |
... |
other arguments to be passed to the geo |
Other important arguments is; 'space' which proves the space between nodes in the y-direction; 'shift' which shifts nodes in the y-direction.
ggplot layer
Creates centered labels or text in nodes of your sankey plot. Needs to have the exact same aesthetics as the call to 'geom_sankey' to work.
geom_sankey_label( mapping = NULL, data = NULL, position = "identity", na.rm = FALSE, show.legend = NA, space = NULL, type = "sankey", width = 0.1, inherit.aes = TRUE, ... ) geom_sankey_text( mapping = NULL, data = NULL, position = "identity", na.rm = FALSE, show.legend = NA, space = NULL, type = "sankey", width = 0.1, inherit.aes = TRUE, ... )geom_sankey_label( mapping = NULL, data = NULL, position = "identity", na.rm = FALSE, show.legend = NA, space = NULL, type = "sankey", width = 0.1, inherit.aes = TRUE, ... ) geom_sankey_text( mapping = NULL, data = NULL, position = "identity", na.rm = FALSE, show.legend = NA, space = NULL, type = "sankey", width = 0.1, inherit.aes = TRUE, ... )
mapping |
provide you own mapping. both x and y need to be numeric. |
data |
provide you own data |
position |
change position |
na.rm |
remove missing values |
show.legend |
show legend in plot |
space |
space between nodes in the y-direction |
type |
Either 'sankey' which centers around the x axis or 'alluvial' which starts at y = 0 and moves upward. |
width |
width of nodes |
inherit.aes |
should the geom inherit aesthetics |
... |
other arguments to be passed to the geom |
ggplot layer
Prepares a 'wide' data frame into a format that 'geom_sankey' or 'geom_alluvial' understands. Useful to show flows between dimensions in dataset.
make_long(.df, ..., value = NULL)make_long(.df, ..., value = NULL)
.df |
a data frame |
... |
unquoted columnnames of df that you want to include in the plot. |
value |
if each row have a weight this weight could be kept by providing column name of weight. |
a longer data frame
Minimal themes for sankey, alluvial and sankey bump plots
theme_sankey( base_size = 11, base_family = "", base_line_size = base_size/22, base_rect_size = base_size/22 ) theme_alluvial( base_size = 11, base_family = "", base_line_size = base_size/22, base_rect_size = base_size/22 ) theme_sankey_bump( base_size = 11, base_family = "", base_line_size = base_size/22, base_rect_size = base_size/22 )theme_sankey( base_size = 11, base_family = "", base_line_size = base_size/22, base_rect_size = base_size/22 ) theme_alluvial( base_size = 11, base_family = "", base_line_size = base_size/22, base_rect_size = base_size/22 ) theme_sankey_bump( base_size = 11, base_family = "", base_line_size = base_size/22, base_rect_size = base_size/22 )
base_size |
base font size, given in pts. |
base_family |
base font family |
base_line_size |
base size for line elements |
base_rect_size |
base size for rect elements |