prettymap: Plot A Pretty Map

Description Usage Arguments Examples

Description

This function executes everything in plotexpression, then draws north arrow and scale bar using addnortharrow and addscalebar. Specify that plot is in a non lat/lon projection by passing scale.plotepsg=... or plotunit="m".

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
prettymap(plotexpression, oma = c(0, 0, 0, 0), mai = c(0, 0, 0, 0),
  drawbox = FALSE, box.lwd = 1, drawscale = TRUE,
  scale.pos = "bottomleft", scale.htin = 0.1, scale.widthhint = 0.25,
  scale.unitcategory = "metric", scale.style = "bar",
  scale.bar.cols = c("black", "white"), scale.lwd = 1,
  scale.linecol = "black", scale.padin = c(0.15, 0.15),
  scale.labelpadin = 0.08, scale.label.cex = 0.8,
  scale.label.col = "black", scale.plotunit = NULL, scale.plotepsg = NULL,
  scale.tick.cex = 0.8, drawarrow = FALSE, arrow.pos = "topright",
  arrow.scale = 1, arrow.padin = c(0.15, 0.15), arrow.lwd = 1,
  arrow.cols = c("white", "black"), arrow.border = "black",
  arrow.text.col = "black", title = NULL, ...)

Arguments

plotexpression

An expression to plot the map, can be in brackets. e.g. plot(stuff); text(places, "readme!") or {plot(stuff); text(places, "readme!")}

oma

A vector of length 4 describing the outer margin area. See documentation for graphics::par.

mai

A vector of length 4 describing the margin area in inches. See documentation for graphics::par.

drawbox

TRUE if box should be drawn around map, FALSE otherwise.

box.lwd

The line width of the box

drawscale

TRUE if scalebar should be drawn, FALSE otherwise.

scale.pos

Where to align the scalebar. One of "bottomleft", "bottomright", "topleft", or "topright".

scale.htin

Height (in inches) of the desired scale bar

scale.widthhint

The fraction of the plottable width which the scale bar should (mostly) occupy.

scale.unitcategory

One of "metric" or "imperial"

scale.style

One of "bar" or "ticks".

scale.bar.cols

If style=="bar", the colors to be repeated to make the bar.

scale.lwd

The line width to use when drawing the scalebar

scale.linecol

The line color to use when drawing the scalebar

scale.padin

A vector of length 2 determining the distance in inches between the scalebar and the edge of the plottable area.

scale.labelpadin

The distance between the end of the scalebar and the label (inches)

scale.label.cex

The font size of the label

scale.label.col

The color of the label

scale.plotunit

The unit which the current plot is plotted in, one of cm, m, km, in, ft, mi. or latlon. This parameter is optional if plotepsg is passed.

scale.plotepsg

The projection of the current plot. If extents are valid lat/lons, the projection is assumed to be lat/lon (EPSG:4326), or Spherical Mercator otherwise (EPSG:3857). This is done to work seamlessly with OpenStreetMap packages.

scale.tick.cex

If style=="ticks", the height of interior ticks.

drawarrow

TRUE if north arrow should be drawn, FALSE otherwise

arrow.pos

Where to align the north arrow. One of "bottomleft", "bottomright", "topleft", or "topright".

arrow.scale

Scale the default north arrow to make it bigger or smaller

arrow.padin

A vector of length 2 determining the distance in inches between the scalebar and the edge of the plottable area.

arrow.lwd

The line width outlining the north arrow

arrow.cols

A vector of length 2 determining the two colors to be drawn for the north arrow

arrow.border

The line color outlining the north arrow

arrow.text.col

Color of the "N"

title

Plot title, or NULL if none is desired.

...

Further graphical parameters to set while executing plotting code

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
prettymap(plot(1:5, 1:5, asp=1), scale.plotunit="cm", drawarrow=FALSE)
#add a title
prettymap(plot(1:5, 1:5, asp=1), title="My Plot")

library(maptools)
data(wrld_simpl)
prettymap({plot(wrld_simpl, xlim=c(-66.86, -59.75), ylim=c(43, 47.3))
           text(-62, 44, "Nova Scotia")
           text(-63, 47, "PEI")}, arrow.scale=1.1)

#also works in non-lat/lon coordinate systems
prettymap(plot(1:1000, 1:1000, asp=1),
           scale.plotepsg=26920, drawarrow=FALSE) #specify plot is in UTM Zone 20N

prettymapr documentation built on May 2, 2019, 9:13 a.m.