Force a facetted plot to have specified panel sizesSource:
Takes a ggplot and modifies its facet drawing behaviour such that the widths and heights of panels are set by the user.
unitvector for setting panel heights.
unitvector for setting panel widths.
TRUE, widths and heights specified in
"null" units are proportional. If
"null" units in x- and y-direction vary independently.
Forcing the panel sizes should in theory work regardless of what
facetting choice was made, as long as this function is called after the
facet specification. Even when no facets are specified, ggplot2 defaults to
ggplot2::facet_null() specification; a single panel.
force_panelsizes works by wrapping the original panel drawing
function inside a function that modifies the widths and heights of panel
grobs in the original function's output gtable.
numeric vectors, panel sizes are
defined as ratios i.e. relative
cols vectors are repeated or shortened to fit the number of panels
in their direction. When
changes are made in that direction.
respect = NULL, default behaviour specified elsewhere is
No attempt is made to guarantee that the plot fits the output device. The
space argument in
ggplot2::facet_grid() will be
overruled. When individual panels span multiple rows or columns, this
function may not work as intended.