Aug 5, 2024
git pull
to get all the code.01_03_ggplot2_maps.R
.map_data()
function from ggplot2 to get map datasets.world_map <- map_data("world")
geom_map()
to create a blank canvas.coord_map()
to apply an orthogonal projection.usa_map <- map_data("state")
vote_data <- map_data("vote_repub")
left_join()
to combine voting data with U.S. map data:
voting_data <- left_join(usa_map, vote_data, by = "state")
aes(x = long, y = lat, group = group, fill = republican_proportion)
.geom_polygon()
for states.scale_fill_gradient2()
to set the midpoint color as white.theme_minimal()
to clean up the visual.