INTERACTIVE MAP

World GDP in 2014

In [1]:
import chart_studio.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)
import pandas as pd
import os
path = "C:/Users/HP/Documents/Python Anaconda/Python for Data Science and Machine Learning Bootcamp/Refactored_Py_DS_ML_Bootcamp-master/09-Geographical-Plotting"
os.chdir(path)
df = pd.read_csv('2014_World_GDP')
df.head()
Out[1]:
COUNTRY GDP (BILLIONS) CODE
0 Afghanistan 21.71 AFG
1 Albania 13.40 ALB
2 Algeria 227.80 DZA
3 American Samoa 0.75 ASM
4 Andorra 4.80 AND
In [2]:
data = dict(type = 'choropleth',
            colorscale = 'Greens',
            locations = df['CODE'],
            z = df['GDP (BILLIONS)'],
            text = df['COUNTRY'],
            marker = dict(line = dict(color = 'rgb(12,12,12)',width = 1.5))
            )
In [3]:
layout = dict(
    title = '2014 Global GDP',
    geo = dict(
        showframe = False,
        showlakes=True, lakecolor='rgb(85,173,240)',
        projection = {'type':'natural earth'}
    )
)

MOVE the Whole Planet!

In [4]:
choromap3 = go.Figure(data=[data], layout=layout)
iplot(choromap3)