Learn R Programming

phyloregion (version 1.0.2)

plot_swatch: Plot shapefile polygons based on slot values

Description

plot_swatch maps discretized values of a quantity based on their quantiles.

Usage

plot_swatch(
  x,
  values,
  k = 10,
  palette = "Blue-Red 3",
  key_label = "",
  leg = 10,
  lwd = 15,
  pos = "bottomleft",
  legend = TRUE,
  border = par("fg"),
  ...
)

Arguments

x

A data frame or object of the class SpatialPolygonsDataFrame

values

Variable in the SpatialPolygonsDataFrame for which to discretize the values of the quantity.

k

Numeric, the desired number of bins to discretize.

palette

name of the palette to generate colors from. The name is matched to the list of available color palettes from the hcl.colors function in the grDevices package.

key_label

label for the color key

leg

Numeric, length of the legend

lwd

numeric, line width of the legend.

pos

location to position the legend such as “bottomright”, “bottomleft”, “topleft”, and “topright”.

legend

logical indicating whether to add a legend to the map.

border

plot polygons in SpatialPolygons object

Further arguments passed to or from other methods.

Value

Returns no value, just map swatch of colors in geographic space!

See Also

SpatialPolygons-class

Examples

Run this code
# NOT RUN {
library(sp)
s <- readRDS(system.file("nigeria/SR_Naija.rds", package = "phyloregion"))
plot_swatch(s, values = s$SR, k = 20)
# }

Run the code above in your browser using DataLab