-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathelement_textbox.Rd
171 lines (150 loc) · 5.02 KB
/
element_textbox.Rd
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/element-textbox.R
\name{element_textbox}
\alias{element_textbox}
\alias{element_textbox_simple}
\title{Theme element that enables markdown text in a box.}
\usage{
element_textbox(
family = NULL,
face = NULL,
size = NULL,
colour = NULL,
fill = NULL,
box.colour = NULL,
linetype = NULL,
linewidth = NULL,
hjust = NULL,
vjust = NULL,
halign = NULL,
valign = NULL,
lineheight = NULL,
margin = NULL,
padding = NULL,
width = NULL,
height = NULL,
minwidth = NULL,
maxwidth = NULL,
minheight = NULL,
maxheight = NULL,
r = NULL,
orientation = NULL,
color = NULL,
box.color = NULL,
debug = FALSE,
inherit.blank = FALSE
)
element_textbox_simple(
family = NULL,
face = NULL,
size = NULL,
colour = NULL,
fill = NA,
box.colour = NULL,
linetype = 0,
linewidth = 0.5,
hjust = 0.5,
vjust = 0.5,
halign = 0,
valign = 1,
lineheight = 1.2,
margin = ggplot2::margin(0, 0, 0, 0),
padding = ggplot2::margin(0, 0, 0, 0),
width = grid::unit(1, "npc"),
height = NULL,
minwidth = NULL,
maxwidth = NULL,
minheight = NULL,
maxheight = NULL,
r = grid::unit(0, "pt"),
orientation = "upright",
color = NULL,
box.color = NULL,
debug = FALSE,
inherit.blank = FALSE
)
}
\arguments{
\item{family}{Font family}
\item{face}{Font face}
\item{size}{Font size (in pt)}
\item{colour, color}{Text color}
\item{fill}{Fill color of the enclosing box}
\item{box.colour, box.color}{Line color of the enclosing box (if different from the text color)}
\item{linetype}{Line type of the enclosing box (like \code{lty} in base R)}
\item{linewidth}{Line width of the enclosing box (measured in mm, just like \code{size} in
\code{\link[ggplot2:element]{ggplot2::element_line()}}).}
\item{hjust}{Horizontal justification}
\item{vjust}{Vertical justification}
\item{halign}{Horizontal justification}
\item{valign}{Vertical justification}
\item{lineheight}{Line height, in multiples of the font size}
\item{padding, margin}{Padding and margins around the text box.
See \code{\link[gridtext:textbox_grob]{gridtext::textbox_grob()}} for details.}
\item{width, height}{Unit objects specifying the width and height
of the textbox, as in \code{\link[gridtext:textbox_grob]{gridtext::textbox_grob()}}.}
\item{minwidth, minheight, maxwidth, maxheight}{Min and max values for width and height.
Set to NULL to impose neither a minimum nor a maximum.}
\item{r}{Unit value specifying the corner radius of the box}
\item{orientation}{Orientation of the text box. See \code{\link[gridtext:textbox_grob]{gridtext::textbox_grob()}} for details.}
\item{debug}{Not implemented.}
\item{inherit.blank}{See \code{\link[ggplot2:element]{ggplot2::margin()}} for details.}
}
\value{
A ggplot2 theme element that can be used inside a \code{\link[ggplot2:theme]{ggplot2::theme()}}
call.
}
\description{
The theme elements \code{element_textbox()} and \code{element_textbox_simple()} enable Markdown text in a box, with
word wrap. Both functions implement exactly the same functionality; they only differ in the default values
for the various element values. \code{element_textbox()} sets all values that are not specified to \code{NULL}, as is
the usual practice in ggplot2 themes. These missing values are usually completed by inheritance from
parent theme elements. By contrast, \code{element_textbox_simple()} provides meaningful default values for many of
the values that are not usually defined in ggplot2 themes. This makes it simpler to use a textbox element
in the context of an existing theme.
}
\examples{
library(ggplot2)
ggplot(mtcars, aes(disp, mpg)) +
geom_point() +
labs(
title =
"<b><span style = 'font-size:13pt'>Fuel economy vs. engine displacement</span></b><br>
Lorem ipsum *dolor sit amet,* consectetur adipiscing elit, **sed do eiusmod tempor
incididunt** ut labore et dolore magna aliqua. <span style = 'color:red;'>Ut enim ad
minim veniam,</span> quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
commodo consequat.",
x = "displacement (in<sup>3</sup>)",
y = "Miles per gallon (mpg)<br><span style = 'font-size:8pt'>A measure of
the car's fuel efficiency.</span>"
) +
theme(
plot.title.position = "plot",
plot.title = element_textbox_simple(
size = 10,
padding = margin(5.5, 5.5, 5.5, 5.5),
margin = margin(0, 0, 5.5, 0),
fill = "cornsilk"
),
axis.title.x = element_textbox_simple(
width = NULL,
padding = margin(4, 4, 4, 4),
margin = margin(4, 0, 0, 0),
linetype = 1,
r = grid::unit(8, "pt"),
fill = "azure1"
),
axis.title.y = element_textbox_simple(
hjust = 0,
orientation = "left-rotated",
minwidth = unit(1, "in"),
maxwidth = unit(2, "in"),
padding = margin(4, 4, 2, 4),
margin = margin(0, 0, 2, 0),
fill = "lightsteelblue1"
)
)
}
\seealso{
\code{\link[gridtext:textbox_grob]{gridtext::textbox_grob()}}, \code{\link[=element_markdown]{element_markdown()}}, \code{\link[=geom_textbox]{geom_textbox()}}
}