In [1]:
    
import plotly.plotly as py
import plotly.graph_objs as go
    
In [2]:
    
from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot
    
In [3]:
    
init_notebook_mode(connected=True)
    
    
In [4]:
    
data = dict(type = 'choropleth',
           locations = ['AZ', 'CA', 'NY'],
           locationmode = 'USA-states',
           colorscale = 'Greens',
           text = ['Arizona', 'Cali', 'New York'],
           z = [1.0, 2.0, 3.0],
           colorbar = {'title': 'Colorbar Title Goes Here'})
    
In [5]:
    
data
    
    Out[5]:
In [6]:
    
layout = dict(geo={'scope':'usa'})
    
In [7]:
    
choromap = go.Figure(data = [data], layout=layout)
    
In [8]:
    
iplot(choromap)
    
    
In [9]:
    
import pandas as pd
df = pd.read_csv('2011_US_AGRI_Exports')
    
In [10]:
    
df.head()
    
    Out[10]:
In [11]:
    
data = dict(type = 'choropleth', 
           colorscale = 'YIOrRd',
           locations = df['code'],
           locationmode = 'USA-states',
           z = df['total exports'],
           text = df['text'],
           marker = dict(line = dict(color = 'rgb(255, 255, 255)', width = 2)),
           colorbar = {'title': 'Millions USD'})
    
In [12]:
    
layout = dict(title = '2011 US Agriculture Exports by State', geo = dict(scope='usa', showlakes=True, lakecolor='rgb(85, 173, 240)'))
    
In [13]:
    
layout
    
    Out[13]:
In [14]:
    
choromap2 = go.Figure(data = [data], layout = layout)
#iplot(choromap2)
    
In [15]:
    
df = pd.read_csv('2014_World_GDP')
    
In [16]:
    
data = dict(type='choropleth',
           locations= df['CODE'],
           z = df['GDP (BILLIONS)'],
           text = df['COUNTRY'],
           colorbar = {'title': 'GDP in Billions USD'})
    
In [17]:
    
layout = dict(title = '2014 Global GDP', geo = dict(showframe=False, projection = {'type':'Mercator'}))
    
In [18]:
    
choromap3 = go.Figure(data = [data], layout = layout)
    
In [19]:
    
iplot(choromap3)