Learn R Programming

inlmisc (version 0.4.3)

AddInsetMap: Add Inset Map to Plot

Description

This function can be used to add an inset map to a plot.

Usage

AddInsetMap(p, col = c("#D8D8D8", "#BFA76F"), main.label = list(label =
  NA, adj = NULL), sub.label = list(label = NA, adj = NULL),
  loc = "topright", inset = 0.02, width = NULL, e = NULL,
  bty = c("o", "n"))

Arguments

p

'SpatialPolygons'. Polygon describing the large map.

col

'character'. Vector of length 2 giving the colors for filling the large map polygon p and the smaller plot extent rectangle.

main.label

'list'. List with components label and adj. The text label and position (x and y adjustment of the label) for the large map, respectively.

sub.label

'list'. Identical to the main.label argument but for the plot extent rectangle.

loc

'character'. Position of the inset map in the main plot region; see GetInsetLocation function for keyword descriptions.

inset

'numeric'. Inset distance(s) from the margins as a fraction of the main plot region. Defaults to 2 percent of the axis range.

width

'numeric'. Width of the inset map in inches.

e

'numeric'. Vector of length 4 describing the extent of the smaller axis-aligned rectangle (relative to the larger map polygon). Defaults to the user coordinate extent of the main plot region, see par("usr").

bty

'character'. The type of box to be drawn about the inset map. A value of "o" (the default) results in a box and a value of "n" supresses the box.

Value

Used for the side-effect of a inset map drawn on the current graphics device.

See Also

PlotMap

Examples

Run this code
# NOT RUN {
file <- system.file("extdata/county.geojson", package = "inlmisc")[1]
county <- rgdal::readOGR(file)
ext <- c(-113.4005, -112.2764, 43.30, 44.11)
PlotMap(county, xlim = ext[1:2], ylim = ext[3:4], dms.tick = TRUE)
sp::plot(county, add = TRUE)
inlmisc::AddInsetMap(county, width = 2, main.label = list("IDAHO", adj = c(0, -10)),
                     sub.label=list("Map area", adj = c(0, -4)), loc = "topright")

# }

Run the code above in your browser using DataLab