Description Usage Format Details Examples
The data frame us_income
provides median income, population number, and
population density for each state, as well as the state's geometry. The data
frame us_income_cartogram
holds the same information but the geometries
have been adjusted so that their area is proportional to the population
number of the state. The data frame us_counties_income
provides county-level
data.
1 2 3 4 5 |
An object of class sf
(inherits from data.frame
) with 51 rows and 8 columns.
Data was obtained from the US Census, 2015 ACS.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | ggplot(US_income, aes(fill = population)) +
geom_sf(color = "grey30", size = 0.3, alpha = 0.5) +
scale_fill_viridis_c()
US_income %>%
filter(GEOID != "11") %>% # remove DC, since it has atypical population density
mutate(popdens = as.numeric(popdens)) %>%
ggplot(aes(fill = log(popdens))) +
geom_sf(color = "grey30", size = 0.3, alpha = 0.5) +
scale_fill_viridis_c()
ggplot(US_income, aes(fill = population)) +
geom_sf(color = "grey30", size = 0.3, alpha = 0.5) +
scale_fill_viridis_c()
p1 <- ggplot(US_income, aes(fill = median_income)) +
geom_sf(color = "grey30", size = 0.3, alpha = 0.7) +
scale_fill_viridis_c()
p2 <- ggplot(US_income_cartogram, aes(fill = median_income)) +
geom_sf(color = "grey30", size = 0.3, alpha = 0.7) +
scale_fill_viridis_c()
plot_grid(p1, p2, ncol = 1)
library(statebins)
filter(US_income, name != "Puerto Rico", GEOID != "11") %>%
ggplot(aes(state = name, fill = median_income)) +
geom_statebins(family = dviz.supp::dviz_font_family,
lbl_size = 14/.pt) +
coord_equal() +
scale_fill_viridis_c() +
theme_statebins(base_family = dviz.supp::dviz_font_family)
ggplot(US_counties_income, aes(fill = log(as.numeric(popdens)))) +
geom_sf(color = NA) +
coord_sf(datum = NA) +
scale_fill_viridis_c(option = "A", name = "popdens") + theme_map() +
theme(legend.position = "bottom")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.