Skip to contents

Plot the polygon clusters produced by hotspot_dbscan() with reasonable defaults. Polygons can be filled according to their count, proportion or rank, and optionally labelled with the same values.

Usage

# S3 method for class 'hspt_s'
autoplot(
  object,
  col_fill = c("n", "prop", "rank", "none"),
  col_label = "none",
  ...,
  basemap_type = "none",
  basemap_zoom = NULL,
  basemap_attribution = NULL,
  quiet = TRUE
)

# S3 method for class 'hspt_s'
autolayer(
  object,
  col_fill = c("n", "prop", "rank", "none"),
  col_label = "none",
  ...
)

# S3 method for class 'hspt_s'
hotspot_map(
  object,
  mapping = NULL,
  col_fill = c("n", "prop", "rank", "none"),
  col_label = "none",
  ...,
  basemap_type = "osm",
  basemap_zoom = NULL,
  basemap_attribution = NULL,
  caption = NULL,
  quiet = TRUE
)

Arguments

object

An object with class hspt_s, as produced by hotspot_dbscan().

col_fill

A single string specifying the column used for the fill aesthetic: "n" (the default), "prop" or "rank". Use "none" to draw unfilled polygons with the default ggplot2 border colour. Set colour in ... to use a different border colour.

col_label

One or more strings specifying the columns used for labels shown in each cluster: "none" (the default), or any combination of "n", "prop" and "rank". Multiple labels are separated by newlines. Proportions are formatted as percentages and ranks as ordinal numbers. Labels use a semi-transparent background chosen to contrast with the base map.

...

Static aesthetics and other arguments passed to ggplot2::geom_sf(), e.g. colour, fill or alpha.

basemap_type

A map type passed to the type argument of ggspatial::annotation_map_tile(), or "none" for no base map. autoplot() defaults to "none" and hotspot_map() defaults to "osm". A base map requires an internet connection unless the required tiles are cached. When a base map is used, the hotspot layer is drawn with alpha = 0.75, overriding any alpha value supplied in ....

basemap_zoom

The zoom level passed to ggspatial::annotation_map_tile(), or NULL to choose it automatically.

basemap_attribution

Attribution for the tile provider, or NULL to use the statement known for basemap_type. A non-empty string is required for a custom or otherwise unknown map type.

quiet

If TRUE (the default), suppress progress bars and other messages. If FALSE, show tile-download progress and other messages.

mapping

For hotspot_map(), this must be NULL. Hotspot-result objects determine their own aesthetic mappings.

caption

For hotspot_map(), additional text to display in the map caption, or NULL for no additional text. Base-map attribution and any explanatory caption generated by the plotting method are retained, with explanatory text above this caption and attribution below it.

Value

autoplot() and hotspot_map() return ggplot2::ggplot objects. autolayer() returns one or more layers that can be added to a ggplot2::ggplot object.

Functions

  • autolayer(hspt_s): Create ggplot layers for DBSCAN hotspot clusters.

  • hotspot_map(hspt_s): Create an automatic map of DBSCAN clusters.