Skip to contents

Draw a scalebar on a map created by mapPlot() or plot,coastline-method(). For plots made otherwise, see ‘Details’.

Usage

mapScalebar(
  x,
  y = NULL,
  length,
  lwd = 1.5 * par("lwd"),
  cex = par("cex"),
  col = "black",
  debug = getOption("oceDebug")
)

Arguments

x, y

position of the scalebar. Eventually these two items may be handled similarly to the corresponding arguments in legend(), but at the moment y must be NULL and x must be "top", "topleft" or "topright".

length

the distance to indicate, in kilometres. If not provided, a reasonable choice is made, based on the existing plot.

lwd

line width of the scalebar.

cex

character expansion factor for the scalebar text.

col

color of the scalebar.

debug

an integer specifying whether debugging information is to be printed during the processing. This is a general parameter that is used by many oce functions. Generally, setting debug=0 turns off the printing, while higher values suggest that more information be printed. If one function calls another, it usually reduces the value of debug first, so that a user can often obtain deeper debugging by specifying higher debug values.

Details

It is also possible to use this with any plot, but the results will only make sense if the aspect ratio is set properly so that an item that is circular in nature is (very closely) circular on the plot. This aspect ratio condition is met by both mapPlot() and plot,coastline-method().

The scale is appropriate to the centre of the plot, and will become increasingly inaccurate away from that spot, with the error depending on the projection and the fraction of the earth that is shown.

Author

Dan Kelley

Examples

# \donttest{
library(oce)
data(coastlineWorld)
# Arctic Ocean
par(mar = c(2.5, 2.5, 1, 1))
mapPlot(coastlineWorld,
    latitudelim = c(60, 120), longitudelim = c(-130, -50),
    col = "lightgray", projection = "+proj=stere +lat_0=90"
)
mapScalebar()

# }