Using the usmap
and the scatterpie
packages this could be achieved via ggplot2
like so:
- Add coordinates for the pies to your data. In the code below I use the coordinates of the state centers provided by
usmapdata::centroid_labels
- Add the pies from your data via
geom_scatterpie
library(usmap)
library(ggplot2)
library(scatterpie)
states <- us_map("states")
centroids <- usmapdata::centroid_labels("states")[c("x", "y", "abbr")]
data <- merge(data, centroids, by.x = "region", by.y = "abbr", all.x = TRUE)
plot_usmap(regions = "states") +
geom_scatterpie(aes(x, y, group = region),
data = data, cols = c("gas", "coal", "wind", "solar")
) +
geom_text(aes(x, y, label = region),
data = data, vjust = 1, nudge_y = -100000
)

EDIT If you want to exclude some states (or include only some states) you could do so via the exclude
or include
argument of plot_usmap
:
plot_usmap(regions = "states", exclude = c("AK", "HI")) +
geom_scatterpie(aes(x, y, group = region),
data = data, cols = c("gas", "coal", "wind", "solar")
) +
geom_text(aes(x, y, label = region),
data = data, vjust = 1, nudge_y = -100000
)
