Skip to contents

Styles the links between layers: whether they are drawn (show; MiRA hides them by default), their color, a weight filter, how much they curve, and between which layers they are shown (pairs). Add it to a plot made with mira().

Usage

mira_interlayer(
  show,
  color_by,
  color,
  min_weight,
  curvature,
  pairs,
  color_values,
  color_scale,
  color_palette,
  color_reverse,
  color_limits
)

Arguments

show

TRUE or FALSE: draw interlayer links.

color_by

Link column to color interlayer links by. NULL or NA = default.

color

A constant link color: a color name or "#rrggbb". Give color_by or color, not both.

min_weight

Hide links with weight below this value (0 or more, in the units of the data's weight column).

curvature

Curvature of interlayer links, between 0 (straight) and 1 (0.35 = MiRA's default).

pairs

Show only the interlayer links between these pairs of layers: list(c("L1", "L2"), c("L2", "L3")), by layer_name; one pair may be given as a vector, c("L1", "L2"). The order within a pair does not matter. Also turns interlayer links on, unless the same call gives show = FALSE. A pair of layers with no links between them draws nothing. A later pairs replaces an earlier one; there is no value that shows all pairs again.

color_values

Colors for values of the color_by column, named by value. See mira_scales.

color_scale

"categorical" or "continuous". See mira_scales.

color_palette

A named palette for the color_by scale: categorical ("Okabe-Ito", ...) or continuous ("magma", ...); see mira_scales for the list.

color_reverse

TRUE reverses the palette.

color_limits

c(min, max): the gradient runs from min to max instead of the data's range; values outside take the end colors. Gives a continuous scale.

Value

A component, to add to a plot with +.

Details

Interlayer links are drawn only with show = TRUE or pairs: the other arguments alone style links that stay hidden (a color_by still shows its legend).

Examples

library(emln)
net <- load_emln(17) # 4 layers; bird and plant nodes
#> Creating state node map
#> Creating extended link list with node IDs
p <- mira(net, bipartite = TRUE, setA_type = "bird")
#> Bipartite network: drawn as undirected. Use directed = TRUE for a directed one.

# Show interlayer links (hidden by default)
p + mira_interlayer(show = TRUE)
#> Not opened: R is not interactive. Print the plot in an R session, or give `browser` to open it from a script.

# One color, more curved; hide links with weight below 0.5
p + mira_interlayer(show = TRUE, color = "red", curvature = 0.8, min_weight = 0.5)
#> Not opened: R is not interactive. Print the plot in an R session, or give `browser` to open it from a script.

# Only between some layers (this also shows them)
p + mira_interlayer(pairs = list(c("layer_1", "layer_2")))
#> Not opened: R is not interactive. Print the plot in an R session, or give `browser` to open it from a script.

# Color by a link column, and choose the colors (see ?mira_scales)
p + mira_interlayer(show = TRUE, color_by = "type",
                    color_values = c(interlayer = "black"))
#> Not opened: R is not interactive. Print the plot in an R session, or give `browser` to open it from a script.
p + mira_interlayer(show = TRUE, color_by = "type", color_scale = "categorical")
#> Not opened: R is not interactive. Print the plot in an R session, or give `browser` to open it from a script.