In [1]:
import plotly.plotly as py
import plotly.graph_objs as go 
from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot
In [2]:
init_notebook_mode(connected=True) 
In [3]:
import pandas as pd
In [5]:
df = pd.read_csv('2014_World_GDP')
df.head()
Out[5]:
In [6]:
data = dict(
        type = 'choropleth',
        locations = df['CODE'],
        z = df['GDP (BILLIONS)'],
        text = df['COUNTRY'],
        colorbar = {'title' : 'GDP Billions US'},
      ) 
In [11]:
layout = dict(
    title = '2014 Global GDP',
    geo = dict(
        showframe = False,
        projection = {'type':'Mercator'}
    )
)
In [13]:
choromap = go.Figure(data = [data],layout = layout)
iplot(choromap)
No comments:
Post a Comment