geom_choropleth | R Documentation |
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.
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
)
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
|
Note that choropleths have a tendency to be misleading by emphasising geographically larger areas.
A ggplot layer.
The location
aesthetic is required.
geom_choropleth()
understands the same aesthetics as ggplot2::geom_sf()
.
rows matching the region
sf
geometry column
limits as computed by ggplot2::stat_sf()
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")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.