In [1]:
import plotly.plotly as py
import plotly.graph_objs as go
import pandas as pd
from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot
init_notebook_mode(connected=True)
In [2]:
data = dict(type='choropleth', locations=['AZ','CA','NY'],
locationmode='USA-states', colorscale='Greens',
text=['text 1', 'text 2', 'text 3'],
z=[1,2,3], colorbar={'title':'Color bar title here'})
layout = dict(geo={'scope':'usa'})
In [3]:
layout
Out[3]:
In [4]:
choro_map = go.Figure(data=[data], layout=layout)
choro_map
Out[4]:
In [5]:
iplot(choro_map)
In [6]:
world_gdp_df = pd.read_csv('/Users/atma6951/Documents/code/pychakras/pychakras/udemy_ml_bootcamp/Python-for-Data-Visualization/Geographical Plotting/2014_World_GDP')
world_gdp_df.head()
Out[6]:
In [7]:
data = {'type':'choropleth', 'locations':world_gdp_df['CODE'],
'z':world_gdp_df['GDP (BILLIONS)'], 'text':world_gdp_df['COUNTRY'],
'colorbar':{'title':'GDP in Billions USD'}}
layout={'title':'2014 Global GDP',
'geo':{'showframe':False, 'projection':{'type':'Mercator'}}}
choromap3 = go.Figure(data=[data], layout=layout)
In [8]:
iplot(choromap3)
In [ ]: