#!usr/bin/python
# encoding=utf8
import sys
reload(sys)
sys.setdefaultencoding( "utf-8" )
import plotly.plotly as py
import pandas as pd
df = pd.read_csv('G20 data.csv')
data = [ dict(
type = 'choropleth',
locations = df['code'],
z = df['article_number'],
text = df['name'],
#colorscale = [[0,"rgb(5, 10, 172)"],[0.35,"rgb(40, 60, 190)"],[0.5,"rgb(70, 100, 245)"],[0.6,"rgb(90, 120, 245)"],[0.7,"rgb(106, 137, 247)"],[1,"rgb(220, 220, 220)"]],
colorscale=[[0,'#0018ad'],[0.2,'#0222e3'],[0.4,'#3f5afd'],[0.6,'#7083fb'],[0.8,'#90a0fd'],[1,'#a3b0ff']],
autocolorscale = False,
reversescale = True,
marker = dict(
line = dict (
color = 'rgb(180,180,180)',
width = 0.5
) ),
colorbar = dict(
autotick = False,
tickprefix = '',
title = 'number of articles'),
) ]
layout = dict(
title = "G20 countries' scientific articles"
geo = dict(
showframe = False,
showcoastlines = False,
showlocations=True,
showland=True,
landcolor='#f0f0f0',
projection = dict(type = 'Mercator')
)
)
fig = dict( data=data, layout=layout )
py.plot( fig, validate=False, filename='d3-world-map-2')