File: font.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 (66 lines) | stat: -rw-r--r-- 2,459 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
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/font.R
\name{font}
\alias{font}
\title{Change the Appearance of Titles and Axis Labels}
\usage{
font(object, size = NULL, color = NULL, face = NULL, family = NULL, ...)
}
\arguments{
\item{object}{character string specifying the plot components. Allowed values
include: \itemize{ \item \code{"title"} for the main title \item
\code{"subtitle"} for the plot subtitle \item \code{"caption"} for the plot
caption \item \code{"legend.title"} for the legend title \item
\code{"legend.text"} for the legend text \item \code{"x", "xlab", or "x.title"}
for x axis label \item \code{"y", "ylab", or "y.title"} for y axis label \item
\code{"xy", "xylab", "xy.title" or "axis.title"} for both x and y axis
labels \item \code{"x.text"} for x axis texts (x axis tick labels) \item
\code{"y.text"} for y axis texts (y axis tick labels) \item \code{"xy.text"}
or \code{"axis.text"} for both x and y axis texts }}

\item{size}{numeric value specifying the font size, (e.g.: \code{size = 12}).}

\item{color}{character string specifying the font color, (e.g.: \code{color =
"red"}).}

\item{face}{the font face or style. Allowed values include one of
\code{"plain", "bold", "italic", "bold.italic"}, (e.g.: \code{face =
"bold.italic"}).}

\item{family}{the font family.}

\item{...}{other arguments to pass to the function
\code{\link[ggplot2:element]{element_text}()}.}
}
\description{
Change the appearance of the main title, subtitle, caption, axis
 labels and text, as well as the legend title and texts. Wrapper around
 \code{\link[ggplot2:element]{element_text}()}.
}
\examples{
# Load data
data("ToothGrowth")

# Basic plot
p <- ggboxplot(ToothGrowth, x = "dose", y = "len", color = "dose",
              title = "Box Plot created with ggpubr",
              subtitle = "Length by dose",
              caption = "Source: ggpubr",
              xlab ="Dose (mg)", ylab = "Teeth length")
p

# Change the appearance of titles and labels
p +
 font("title", size = 14, color = "red", face = "bold.italic")+
 font("subtitle", size = 10, color = "orange")+
 font("caption", size = 10, color = "orange")+
 font("xlab", size = 12, color = "blue")+
 font("ylab", size = 12, color = "#993333")+
 font("xy.text", size = 12, color = "gray", face = "bold")

# Change the appearance of legend title and texts
p +
 font("legend.title", color = "blue", face = "bold")+
 font("legend.text", color = "red")

}