Hi, i was looking at the USA choropleth maps example and want to use it for another country. i tested by modifying the csv file into the province of thailand and the projection to a latitude and longitude of thailand.
# code sample for USA choropleth map
import plotly.plotly as py
import pandas as pd
df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/2011_us_ag_exports.csv')
for col in df.columns:
df[col] = df[col].astype(str)
scl = [[0.0, 'rgb(242,240,247)'],[0.2, 'rgb(218,218,235)'],[0.4, 'rgb(188,189,220)'],\
[0.6, 'rgb(158,154,200)'],[0.8, 'rgb(117,107,177)'],[1.0, 'rgb(84,39,143)']]
df['text'] = df['state'] + '<br>' +\
'Beef '+df['beef']+' Dairy '+df['dairy']+'<br>'+\
'Fruits '+df['total fruits']+' Veggies ' + df['total veggies']+'<br>'+\
'Wheat '+df['wheat']+' Corn '+df['corn']
data = [ dict(
type='choropleth',
colorscale = scl,
autocolorscale = False,
locations = df['code'],
z = df['total exports'].astype(float),
locationmode = 'USA-states',
text = df['text'],
marker = dict(
line = dict (
color = 'rgb(255,255,255)',
width = 2
) ),
colorbar = dict(
title = "Millions USD")
) ]
layout = dict(
title = '2011 US Agriculture Exports by State<br>(Hover for breakdown)',
geo = dict(
scope='usa',
projection=dict( type='albers usa' ),
showlakes = True,
lakecolor = 'rgb(255, 255, 255)'),
)
fig = dict( data=data, layout=layout )
py.iplot( fig, filename='d3-cloropleth-map' )
# portion modified.
data = [ dict(
...
locationmode = 'country-names',
...)]
layout = dict(
...
geo=dict(
scope='asia',
projection = dict(
rotation=dict(
lon = 100.750112,
lat = 13.689999,
roll = 0,
)
),
),
...)
I modified the usa states to provinces of thailand based on the list of province stated in wikipedia
portion of modified csv
|code|state|
|---|---|
|ANCR|Amnat Charoen|
|ANTH|Ang Thong|
|PNSA|Phra Nakhon Si Ayutthaya|
|BAKK|Bangkok|
I tried with locationmode with USA-states and county names, both generated same result.
I tried with scope asia with the direct latitude and longitude but it doesnt generate what I need.
I need a choropleth map of thailand where I have some statistics pre-calculated to be displayed, similar to the csv file.
Is it possible to do the choropleth map of thailand using plot.ly?