Learn R Programming

inlmisc (version 0.3.2)

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 = c("bottomleft", "topleft", "topright", "bottomright"), inset = 0.02,
  width = NULL)

Arguments

p

'SpatialPolygons'. Polygon describing the large map.

col

'list'. 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: "bottomleft", "topleft", "topright", or "bottomright" to denote scale location.

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.

Value

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

Details

The smaller axis-aligned rectangle (relative to the larger map polygon) is defined by the user coordinate extent of the main plot region, see par("usr").

See Also

PlotMap

Examples

Run this code
# NOT RUN {
nc <- maptools::readShapePoly(system.file("shapes/sids.shp", package = "maptools")[1],
                              proj4string=sp::CRS("+proj=longlat +datum=NAD27"))
bb <- sp::bbox(nc[100, ])
xlim <- grDevices::extendrange(bb["x", ])
ylim <- grDevices::extendrange(bb["y", ])
PlotMap(raster::crs(nc), xlim = xlim, ylim = ylim, dms.tick = TRUE)
sp::plot(nc, add = TRUE)
AddInsetMap(nc, width = 3, main.label = list("North Carolina", adj = c(1.8, 3)),
            sub.label = list("Map area", adj = c(1.5, 0.5)), loc = "topright")

# }

Run the code above in your browser using DataLab