% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/panel-layout.R
\name{panel_layout}
\alias{panel_layout}
\title{Configure a custom multi-panel layout}
\usage{
panel_layout(spec, mar = c(2, 2, 3, 1), widths = NULL, heights = NULL)
}
\arguments{
\item{spec}{Either a length-2 integer vector \code{c(nrow, ncol)} for a
uniform grid, or a numeric matrix of panel positions to pass to
\code{graphics::layout()}.}

\item{mar}{Numeric vector of length 4 giving panel margins. Default
\code{c(2, 2, 3, 1)} matches cograph's multi-panel margin convention.}

\item{widths, heights}{Optional numeric vectors of column widths and row
heights. Only valid when \code{spec} is a matrix; passed straight to
\code{graphics::layout()}. Supplying them with a uniform-grid
\code{spec} is an error, since \code{par(mfrow=...)} has no
widths/heights concept.}
}
\value{
Invisibly returns a list of previous \code{par()} settings that
can be passed back to \code{graphics::par()} to restore the prior
device state. For both spec shapes the snapshot includes
\code{mfrow}, so \code{par(old_par)} also resets any
\code{graphics::layout()} partitioning that this call introduced.
}
\description{
Sets up a multi-panel device layout for use with cograph plotting
functions called with \code{combined = FALSE}. Returns a \code{par()}
snapshot of the previous device state so the caller can restore it
via \code{on.exit(graphics::par(old_par))}.
}
\details{
Use \code{spec = c(nrow, ncol)} for a uniform grid (delegates to
\code{graphics::par(mfrow = ...)}). Use \code{spec = <matrix>} for a
non-uniform layout (delegates to \code{graphics::layout()}); the matrix
values name panel cells, so \code{matrix(c(1, 1, 2, 3), 2, 2)} produces
one wide cell on top and two cells on the bottom row.
}
\section{Combined-flag scope}{

\code{panel_layout()} composes with the \code{combined = FALSE} opt-out
on cograph's multi-panel plot functions. Single-network calls like
\code{splot(some_tna_object)} do not honor \code{combined} — there is
nothing for it to gate. Pass \code{combined = FALSE} only to the
multi-panel hosts: \code{plot_netobject_group()},
\code{plot_netobject_ml()}, \code{plot_net_bootstrap_group()},
\code{plot_group_permutation()}, \code{plot_difference()},
\code{splot.net_mlvar(type = "all")}, \code{plot_network_evolution()},
\code{plot.cograph_motifs(type = "network")},
\code{plot.cograph_motif_result(type = "patterns")},
\code{plot.cograph_motif_analysis(type = "patterns")},
\code{plot.tna_disparity(type = "comparison")}, and \code{splot()} on
\code{group_tna} / similar list-of-plottables inputs.
}

\examples{
mat <- matrix(c(0, .5, .3, .5, 0, .4, .3, .4, 0), 3, 3)
colnames(mat) <- rownames(mat) <- c("A", "B", "C")
net1 <- as_cograph(mat)
net2 <- as_cograph(mat * 0.5)

# Uniform 1 x 2 grid
op <- panel_layout(c(1, 2))
splot(net1, combined = FALSE)
splot(net2, combined = FALSE)
graphics::par(op)

}
