Manual layout for panelsSource:
facet_manual() the layout for panels is determined by a custom design.
Inspired by base-R graphics
layout() function, this
variant of facets offers more freedom in how panels are displayed, but
comes with less guarantees that it looks right.
facet_manual( facets, design = NULL, widths = NULL, heights = NULL, respect = FALSE, drop = TRUE, strip.position = "top", scales = "fixed", axes = "margins", remove_labels = "none", labeller = "label_value", trim_blank = TRUE, strip = strip_vanilla() )
A set of variables or expressions quoted by
vars()and defining faceting groups on the rows or columns dimension. The variables can be named (the names are passed to
For compatibility with the classic interface, can also be a formula or character vector. Use either a one sided formula,
~a + b, or a character vector,
Specification of panel areas in the layout. Can either be specified as a
character(1)string or as a
matrix. See examples.
- widths, heights
unitvector setting the sizes of panels. A
numericvector is converted to relative
"null"units. Alternatively, when
NULL(default), the sizes are set per instructions of coord or theme aspect ratio. Note that these widths and heights apply to the cells where panels can be drawn. In between such cells, room will be made to fit plot decoration such as paddings, axes and strips.
TRUE, widths and heights specified in
"null"units are proportional. If
"null"units in the x- and y-directions can vary independently. Alternatively, when
respectparameter takes instructions from the coord or theme.
TRUE, the default, all factor levels not used in the data will automatically be dropped. If
FALSE, all factor levels will be shown, regardless of whether or not they appear in the data.
By default, the labels are displayed on the top of the plot. Using
strip.positionit is possible to place the labels on either of the four sides by setting
strip.position = c("top", "bottom", "left", "right")
logical(1)whether scales are shared across facets or allowed to vary. One of the following:
Scales are shared across all facets (default).
x-scales are allowed to vary.
y-scales are allowed to vary.
Both scales can vary
logical(1)where axes should be drawn. One of the following:
Only draw axes at the outer margins (default).
Draw axes at the outer margins and all inner x-axes too.
Draw axes at the outer margins and all inner y-axes too.
Draw the axes for every panel.
logical(1)determining whether axis text is displayed at inner panels. One of the following:
Display axis text at all axes (default).
Display axis text at outer margins and all inner y-axes.
Display axis text at outer margins and all inner x-axes.
Only display axis text at the outer margins.
A function that takes one data frame of labels and returns a list or data frame of character vectors. Each input column corresponds to one factor. Thus there will be more than one with
vars(cyl, am). Each output column gets displayed as one separate line in the strip label. This function should inherit from the "labeller" S3 class for compatibility with
labeller(). You can use different labeling functions for different kind of labels, for example use
label_parsed()for formatting facet labels.
label_value()is used by default, check it for more details and pointers to other options.
TRUE(default), the design will be trimmed to remove empty rows and columns.
An object created by a call to a strip function, such as
# A standard plot p <- ggplot(mtcars, aes(mpg, wt)) + geom_point() # The `design` argument can be a character string. # New rows are indicated by newline symbol (`\n`), which are added # automatically for multi-line strings. # The `#`-symbol indicates empty cells. design <- " A## AB# #BC ##C " p + facet_manual(~ cyl, design) # Alternatively, the `design` argument can be a matrix. # Using `NA`s will leave the cell empty. design <- matrix(c(1,2,3,3), 2, 2, byrow = TRUE) p + facet_manual(~ cyl, design) # The sizes of columns and rows can be adjusted with the `widths` and # `heights`parameters respectively. p + facet_manual( ~ cyl, t(design), widths = c(2, 1), heights = c(2, 1), respect = TRUE )