I am trying to build a choropleth map in R and found very promising code using the function plot_geo()here: https://plot.ly/r/choropleth-maps/ . Unfortunately, I could not understand how to adapt the code to my problem, and I could not find useful explanations on the Internet.
Here is the source code:
g <- list(
scope = 'usa',
projection = list(type = 'albers usa'),
showlakes = TRUE,
lakecolor = toRGB('white')
)
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<br>(Hover for breakdown)',
geo = g
)
The data I use is a numerical value that defines the color to fill in the country and the two-digit ISO code of all European countries. Therefore, since I want to create a map of Europe, I install scope = 'europe', but I do not understand what it does projection = list(type = 'albers usa')and what I need to indicate instead. I just threw it that way.
g <- list(
scope = 'europe')
, "", .. - .
plot_geo(data) %>%
add_trace(
z = ~value, locations = ~LAND_ISO,
color = ~value, colors = 'Purples'
) %>%
colorbar(title = "") %>%
layout(geo = g
)
plot_geo
, , , ISO locations. , ? locationmode, ? ?
- ?
!