In: Computer Science
How do I create a choropleth map of the United States where there are two maps. One that shows the states and one that shows the counties, in PYTHON, from the beginning. When I hover a state or county the border should be highlighted and the name of the state/county displayed. I would like to use Plotly and the covid-19 dataset that I have. It contains latitude and longitude coordinates for each state or county.
Answer :
How do I create a choropleth map of the United States where there are two maps. One that shows the states and one that shows the counties, in Rstudio, from the beginning. When I hover a state or county the border should be highlighted and the name of the state/county displayed.
I need to do this so that I can display the COVID-19 data that I have.
library(ggplot2)
library(scales)
library(ggmap)
library(viridis)
dataset$id <- rownames("dataset")
newUS <- fortify(US3, region = "id")
newdf <- merge(newUS, US3@data, by = "id")
Myplot <- ggplot() +
geom_polygon(data = newdf, aes(fill = Bush_pct,
x = long,
y = lat,
group = group)) +
theme_nothing(legend = TRUE) + coord_map() + ggtitle("column_name")
+ theme(plot.title = element_text(hjust =0.5))
NicerPlot <- Myplot + scale_fill_viridis(option = "magma",
direction = -1)
NicerPlot
I hope this answer is helpful to you, please upvote my answer. I'm in need of it.. Thank you..