2.1.9.2.Choropleth Maps - World
1. 使用library
import plotly.plotly as py
import plotly.graph_objs as go
from plotly.offline import download_plotlyjs,init_notebook_mode,plot,iplot
init_notebook_mode(connected = True)2.從實際資料中繪製Choropleth Map
import pandas as pd df = pd.read_csv('2014_World_GDP') df.head()
data = dict( type = 'choropleth', locations = df['CODE'], z = df['GDP (BILLIONS)'], text = df['COUNTRY'], colorbar = {'title' : 'GDP Billions US'}, ) layout = dict( title = '2014 Global GDP', geo = dict( showframe = False, projection = {'type':'Mercator'} ) )data = dict( type = 'choropleth', locations = df['COUNTRY'], locationmode = "country names", z = df['GDP (BILLIONS)'], text = df['COUNTRY'], colorbar = {'title' : 'GDP Billions US'}, ) layout = dict( title = '2014 Global GDP', geo = dict( showframe = False, projection = {'type':'Mercator'} ) )

Previous2.1.9.1.Choropleth Maps - USANext2.1.10.Combine data analysis and visualization to tackle real world data sets
Last updated
