Description Usage Arguments Details Warnings See Also Examples
Puts a text anywhere on the device, with a logical position (such as
"topleft" or "center") specified relative to one of three plotting
regions (figure
(default), device
or plot
)
1 |
text |
a character string to be plotted |
region |
in which region of the device the label should be placed |
pos |
position relative to the region ("topleft" by default) |
cex |
magnification of the characters. See |
... |
any further parameters (e.g. |
The main purpose of this function is to add labels (such as "A", "B", ...) to figures
fig_label
is not compatible with ggplot2
. However,
par(mfrow=...) and layout() work just fine.
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 | ## Basic use:
par(mfrow=c(2,2))
for(x in LETTERS[1:4]) {
plot(rnorm(100))
fig_label(x, cex=2)
}
## Plotting at different positions and in different regions:
plot(rnorm(100))
for(i in c("topleft", "topright", "top",
"left", "center", "right",
"bottomleft", "bottom", "bottomright")) {
fig_label(i, pos=i, cex=2, col="blue")
fig_label(i, pos=i, cex=1.5, col="red", region="plot")
}
## All the different regions:
par(mfrow=c(2,2))
for(x in LETTERS[1:4]) {
plot(rnorm(100))
fig_label("figure region", cex=2, col="red")
fig_label("plot region", region="plot", cex=2, col="blue")
}
fig_label("device region", cex=2, pos="bottomright",
col="darkgreen", region="device")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.