% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/gglasagna.R
\name{gglasagna}
\alias{gglasagna}
\title{Lasagna plots for \code{tf}s using \code{ggplot2}}
\usage{
gglasagna(
  data,
  tf,
  order = NULL,
  label = NULL,
  arg = NULL,
  order_by = NULL,
  order_ticks = TRUE
)
}
\arguments{
\item{data}{A data frame containing the \code{tf} column to visualize.}

\item{tf}{bare name of the \code{tf} column to visualize}

\item{order}{(optional) bare name of a column in \code{data} to define vertical
order of lasagna layers.}

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

\item{arg}{\code{arg} to evaluate \code{y} on}

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

\item{order_ticks}{add horizontal lines indicating borders between levels of
\code{order} (if it is a discrete variable) and labels for its levels?
Defaults to TRUE. Supply a named list to override tick appearance, including
label styling, line type, alpha, rotation, and label placement.
Disable this when faceting; the tick annotations are not designed for faceted layouts.}
}
\value{
a \code{ggplot2} object
}
\description{
Lasagna plots show one color bar for each function.
}
\details{
The vertical order of the lasagna layers is \strong{increasing} in
\itemize{
\item \code{order} (if provided),
\item the values returned by \code{order_by} (if provided),
\item 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 \code{data} and the vertical order of the layers is the
ordering of observations obtained by \code{dplyr::arrange(data, order, order_by(value), row_number())}.
}
\examples{
\donttest{
library(ggplot2)
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 = dplyr::first) +
  facet_wrap(~group, scales = "free")
# order of layers is by "order_by" within "order":
gglasagna(data, fb, label = id, order = group, order_by = dplyr::first)
}
}
\seealso{
Other tidyfun visualization: 
\code{\link{autoplot.tf}()},
\code{\link{ggcapellini}},
\code{\link{ggspaghetti}}
}
\concept{tidyfun visualization}
