inset: Inset plots

Description Usage Arguments Details Examples

View source: R/plot_extra.R

Description

Inset new plots in existing plot windows.

Usage

1
inset(x, y = NULL, pct = 0.25, ...)

Arguments

x

a keyword (see details) or a vector of length two giving the positions on the current plot at which to draw the inset plot along the x-axis

y

ignored if x is a keyword or a vector of length two giving the positions on the current plot at which to draw the inset plot along the y-axis

pct

inset plot scaling (only used if x is a keyword)

...

additional graphical parameters passed to par

Details

x should be of the form x0, x1 and similar for y giving the starting and ending coordinates to draw the inset plot and must be in the range defined in the current plotting area.

Alternatively, x can be a keyword ("bottomright", "bottom", "bottomleft", "left", "topleft", "top", "topright" "right", or "center") giving the approximate location of the inset plot. pct is used to adjust the size.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
op <- par(no.readonly = TRUE)

plot(mpg ~ wt, data = mtcars, col = 'blue')
abline(lm(mpg ~ wt, data = mtcars), col = 'red')
inset('topright', pct = .4)
hist(mtcars$mpg, ann = FALSE, panel.last = box(),
     col = 'dodgerblue2', las = 1)
par(op)

plot(1:10, type = 'n')
op <- par(no.readonly = TRUE)
Map(function(x) {
 inset(x, las = 1, col = 'red', pct = 1/3)
 plot(rnorm(10), ann = FALSE, axes = FALSE, panel.last = box())
 par(op)
 Sys.sleep(0.5)
 }, c('bottomright', 'bottom', 'bottomleft', 'left',
      'topleft', 'top', 'topright', 'right', 'center')
)

raredd/plotr documentation built on Nov. 13, 2018, 7:05 a.m.