Hello i have this code which produces chloropeth map in state level with plotly but i want to produce exactly the same map in counties level. I tried to change the locationmode = ‘USA-states’ to locationmode = ‘USA-counties’ but it does not work. Any ideas? (emergency)
library(plotly)
df <- read.csv(“https://raw.githubusercontent.com/plotly/datasets/master/2011_us_ag_exports.csv”)
df$hover <- with(df, paste(state, ‘
’, “Beef”, beef, “Dairy”, dairy, “
”,
“Fruits”, total.fruits, “Veggies”, total.veggies,
"
", “Wheat”, wheat, “Corn”, corn))
give state boundaries a white border
l <- list(color = toRGB(“white”), width = 2)
specify some map projection/options
g <- list(
scope = ‘usa’,
projection = list(type = ‘albers usa’),
showlakes = TRUE,
lakecolor = toRGB(‘white’)
)
p <- plot_geo(df, locationmode = ‘USA-states’) %>%
add_trace(
z = ~total.exports, text = ~hover, locations = ~code,
color = ~total.exports, colors = ‘Purples’
) %>%
colorbar(title = “Millions USD”) %>%
layout(
title = ‘2011 US Agriculture Exports by State
(Hover for breakdown)’,
geo = g
)