library(mxmaps)
library(leaflet) # for colorNumeric
df_mxmunicipio_2020$value <- df_mxmunicipio_2020$indigenous_language /
df_mxmunicipio_2020$pop
#Viridis color scheme
magma <- c("#000004FF", "#1D1146FF", "#50127CFF", "#822681FF", "#B63779FF",
"#E65163FF", "#FB8761FF", "#FEC387FF", "#FCFDBFFF")
pal <- colorNumeric(magma, domain = df_mxmunicipio_2020$value)
mxmunicipio_leaflet(df_mxmunicipio_2020,
pal,
~ pal(value),
~ sprintf("State: %s<br/>Municipio : %s<br/>Percent Indigenous: %s%%",
state_name, municipio_name, round(value * 100, 1))) %>%
addLegend(position = "bottomright",
pal = pal,
values = df_mxmunicipio_2020$value,
title = "Percent<br>Indigenous<br>Speaking",
labFormat = labelFormat(suffix = "%",
transform = function(x) {100 * x})) %>%
addProviderTiles("CartoDB.Positron")