geom_choropleth {ggautomap} | R Documentation |
Associate regions with counts
Description
Counts the number of occurrences of each location, then by default maps the
count to the fill aesthetic. If your data has only one row per location and
some other field that you'd like to map to aesthetics, use
geom_sf()
or geom_sf_inset()
with stat = "automap"
instead.
Usage
geom_choropleth(
mapping = ggplot2::aes(),
data = NULL,
stat = "choropleth",
position = "identity",
...,
feature_type = NA,
inset = NA,
map_base = "normal",
map_inset = "auto",
na.rm = TRUE,
show.legend = NA,
inherit.aes = TRUE
)
stat_choropleth(
mapping = NULL,
data = NULL,
geom = "sf",
position = "identity",
...,
feature_type = NA,
na.rm = TRUE,
show.legend = NA,
inherit.aes = TRUE
)
Arguments
mapping , data , stat , geom , position , na.rm , show.legend , inherit.aes , ... |
See |
feature_type |
Type of map feature. See |
inset |
Inset configuration; see |
map_base |
Controls the layer with the base map. Possible values are
|
map_inset |
Controls the layer with the inset map. Possible values are
|
Details
Note that choropleths have a tendency to be misleading by emphasising geographically larger areas.
Value
A ggplot layer.
Aesthetics
The location
aesthetic is required.
geom_choropleth()
understands the same aesthetics as ggplot2::geom_sf()
.
Computed variables
- count
rows matching the region
- geometry
sf
geometry column- ...
limits as computed by
ggplot2::stat_sf()
Examples
library(ggplot2)
cartographer::nc_type_example_2 |>
ggplot(aes(location = county)) +
geom_choropleth() +
geom_boundaries(feature_type = "sf.nc") +
scale_fill_steps(low = "#e6f9ff", high = "#00394d") +
coord_automap(feature_type = "sf.nc")