fig_label: Create a label at the top left of the graphics device

Description Usage Arguments Details Warnings See Also Examples

View source: R/fig_label.R

Description

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)

Usage

1
fig_label(text, region = "figure", pos = "topleft", cex = NULL, ...)

Arguments

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 par

...

any further parameters (e.g. col) will be passed to the text function.

Details

The main purpose of this function is to add labels (such as "A", "B", ...) to figures

Warnings

fig_label is not compatible with ggplot2. However, par(mfrow=...) and layout() work just fine.

See Also

layout, par

Examples

 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")

january3/myfuncs documentation built on April 1, 2020, 4:42 a.m.