Lasagna plots show one color bar for each function.

gglasagna(
  data,
  y,
  order = NULL,
  label = NULL,
  arg = NULL,
  order_by = NULL,
  order_ticks = TRUE
)

Arguments

data

the data. Duhh.

y

bare name of the tf column to visualize

order

(optional) bare name of a column in data to define vertical order of lasagna layers.

label

(optional) bare name of a column in data to define labels for lasagna layers. Defaults to names of y, if present, or row numbers.

arg

arg to evaluate y om

order_by

a function applied to each row in y[, arg] that must return a scalar value to define the order of lasagna layers.

order_ticks

add horizontal lines indicating borders between levels of order (if it is a discrete variable) and labels for its levels? Defaults to TRUE. Supply a list of arguments (grep source code for `order_ticks_args``) to override default appearance of labels. Switch this off if you use facetting, it's a hack and will produce nonsense.

Value

a `ggplot2`` object

Details

The vertical order of the lasagna layers is increasing in

  • order (if provided),

  • the values returned by order_by (if provided),

  • and the row number of the observations.

i.e., lowest values are on top so that by default the first layer is the first observation in data and the vertical order of the layers corresponds to the ordering of observations for arrange(data, order, order_by(value), row_number()).

Examples

if (FALSE) { set.seed(1221) data = expand.grid(group = factor(1:5), rep = 1:10) data = dplyr::mutate(data, id = paste(group, rep, sep = "-"), f = tf_rgp(50), fb = tfb(f)) gglasagna(data, f, label = id) gglasagna(data, fb, label = id, order = group) # order is lowest first / on top by default gglasagna(data, f, label = id, order = tf_depth(f)) gglasagna(data, f, label = id, order_by = first) + facet_wrap(~group, scales = "free") # order of layers is by "order_by" within "order": gglasagna(data, fb, label = id, order = group, order_by = first) }