scalebarparams | R Documentation |
Get default scale bar parameters based on the current plot (i.e. par("usr")
).
The algorithm attempts to detect the best equally divisable distance to use for the
scale bar, and returns a list
object with attributes that allow any type of
scale bar to be drawn. The only way to manipulate the values chosen by the algorithm
is to change the widthhint
argument. For generic XY plots, pass plotunit
.
scalebarparams(
plotunit = NULL,
plotepsg = NULL,
widthhint = 0.25,
unitcategory = "metric",
extents = graphics::par("usr")
)
plotunit |
The unit which the current plot is plotted in, one of |
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. |
widthhint |
The fraction of the plottable width which the scale bar should (mostly) occupy. |
unitcategory |
One of "metric" or "imperial" |
extents |
The plot extents |
a list
of parameters: $widthu
(width of the scalebar in human
readable units); $unit
(the human readable unit); $majordivu
(the size
of the divisions in human readable units); $majordivs
(the number of divisions);
$widthplotunit
(width of the scalebar in plotting units); $majordivplotunit
(the width of divisions in plotting units); $labeltext
(label text); and extents
the user extents (par('usr')
) that were used to calculate the parameters.
addscalebar
plot(1:5, 1:5, asp=1)
scalebarparams(plotunit="m")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.