File: facet.Rd

package info (click to toggle)
r-cran-ggpubr 0.6.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 3,240 kB
  • sloc: makefile: 2
file content (88 lines) | stat: -rw-r--r-- 3,266 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/facet.R
\name{facet}
\alias{facet}
\title{Facet a ggplot into Multiple Panels}
\usage{
facet(
  p,
  facet.by,
  nrow = NULL,
  ncol = NULL,
  scales = "fixed",
  short.panel.labs = TRUE,
  labeller = "label_value",
  panel.labs = NULL,
  panel.labs.background = list(color = NULL, fill = NULL),
  panel.labs.font = list(face = NULL, color = NULL, size = NULL, angle = NULL),
  panel.labs.font.x = panel.labs.font,
  panel.labs.font.y = panel.labs.font,
  strip.position = "top",
  ...
)
}
\arguments{
\item{p}{a ggplot}

\item{facet.by}{character vector, of length 1 or 2, specifying grouping
variables for faceting the plot into multiple panels. Should be in the data.}

\item{nrow, ncol}{Number of rows and columns in the panel. Used only when the
data is faceted by one grouping variable.}

\item{scales}{should axis scales of panels be fixed ("fixed", the default),
free ("free"), or free in one dimension ("free_x", "free_y").}

\item{short.panel.labs}{logical value. Default is TRUE. If TRUE, create short
labels for panels by omitting variable names; in other words panels will be
labelled only by variable grouping levels.}

\item{labeller}{Character vector. An alternative to the argument
\code{short.panel.labs}. Possible values are one of "label_both" (panel
labelled by both grouping variable names and levels) and "label_value"
(panel labelled with only grouping levels).}

\item{panel.labs}{a list of one or two character vectors to modify facet panel
labels. For example, panel.labs = list(sex = c("Male", "Female")) specifies
the labels for the "sex" variable. For two grouping variables, you can use
for example panel.labs = list(sex = c("Male", "Female"), rx = c("Obs",
"Lev", "Lev2") ).}

\item{panel.labs.background}{a list to customize the background of panel
labels. Should contain the combination of the following elements: \itemize{
\item \code{color, linetype, size}: background line color, type and size
\item \code{fill}: background fill color. } For example,
panel.labs.background = list(color = "blue", fill = "pink", linetype =
"dashed", size = 0.5).}

\item{panel.labs.font}{a list of aestheics indicating the size (e.g.: 14), the
face/style (e.g.: "plain", "bold", "italic", "bold.italic") and the color
(e.g.: "red") and the orientation angle (e.g.: 45) of panel labels.}

\item{panel.labs.font.x, panel.labs.font.y}{same as panel.labs.font but for
only x and y direction, respectively.}

\item{strip.position}{(used only in \code{facet_wrap()}). By default, the
labels are displayed on the top of the plot. Using \code{strip.position} it
is possible to place the labels on either of the four sides by setting
\code{strip.position = c("top", "bottom", "left", "right")}}

\item{...}{not used}
}
\description{
Create multi-panel plots of a data set grouped by one or two
 grouping variables. Wrapper around \code{\link[ggplot2]{facet_wrap}}
}
\examples{
p <- ggboxplot(ToothGrowth, x = "dose", y = "len",
      color = "supp")
print(p)

facet(p, facet.by = "supp")

# Customize
facet(p + theme_bw(), facet.by = "supp",
  short.panel.labs = FALSE,   # Allow long labels in panels
  panel.labs.background = list(fill = "steelblue", color = "steelblue")
)
}