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??

@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:

https://plot.ly/~prashasti/6

https://plot.ly/~prashasti/7

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

library(plotly)
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’) %>%
add_trace(
z = ~muertes2018, text = ~muertes2018, locations = ~dpto,
color = ~muertes2018, colors = ‘Purples’
) %>%
colorbar(title = “Muertes 2018 (fetales y neonatos)”) %>%
layout(
title = ‘2018 PERU Muertes por departamento
(Fetales y neonatales)’,
geo = g
)

p

three reasons why you should buy plotly pro: support open source, get great support, host your plots and dashboards online