✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
🧬 Learn how to build RNA-Seq data apps with Python & Dash. Register for the May 20 Webinar!

How do I create country specific chlropleth maps?

I am trying to plot a chlropleth map for India and thus I have a data frame with the sate names and codes. I tried to use the code mentioned on the site for the US map. I tried to change the location codes but it is not working.tHow do I create the map for India??

1 Like

@Ashwin for states in India, you need to use the Mapbox maps (not D3 choropleths) and follow this approach:

A few users have made India state choropleths before, here are some examples:



You can download these figures in Python to inspect them with:

import plotly.plotly as py
figure = py.get_figure('https://plot.ly/~prashasti/7')
print figure

How do I create country specific chlropleth maps?

#Database: https://we.tl/t-tNYx6Crbag

Mapa interactivo con R

df <- read.csv(“muertes.csv”)
df$hover <- with(df, paste(depart, ‘
’, “Muertes”, muertes2018, “Fetales %”, pcfet2018, “
“Neonatos %”, pcneo2018))

Dar a los límites departamentales un color blanco

l <- list(color = toRGB(“white”), width = 2)

specify some map projection/options

g <- list(
scope = ‘peru’,
projection = list(type = ‘mercator’),
showlakes = TRUE,
lakecolor = toRGB(‘white’)

p <- plot_geo(df, locationmode = ‘peru’) %>%
z = ~muertes2018, text = ~muertes2018, locations = ~dpto,
color = ~muertes2018, colors = ‘Purples’
) %>%
colorbar(title = “Muertes 2018 (fetales y neonatos)”) %>%
title = ‘2018 PERU Muertes por departamento
(Fetales y neonatales)’,
geo = g


Can I also do that same for any country , say ‘Egypt’ like scope = ‘Egypt’ or are there certain scope the geo-map covers??