{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Choropleth Maps (Flächenkarten)\n", "\n", "### Offline Plotly Nutzung\n", "\n", "Wir importieren alles notwendige und bereiten es dafür vor auch offline zu funktionieren:" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": true }, "outputs": [], "source": [ "import plotly.plotly as py\n", "import plotly.graph_objs as go \n", "from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Jetzt müssen wir das Notebook so einrichten, dass die Karten angezeigt werden:" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "" ], "text/vnd.plotly.v1+html": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "init_notebook_mode(connected=True) " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Mehr Infos zur offline Nutzung von *Plotly* gibt's [hier](https://plot.ly/python/offline/)." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Flächenkarte USA\n", "Die Choropleth Maps (Flächenkarten) sind anfangs etwas schwer zu merken. Ihr könnt immer auf das [Cheatsheet](https://images.plot.ly/plotly-documentation/images/python_cheat_sheet.pdf) zurückgreifen, um eure Erinnerung aufzufrischen." ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": true }, "outputs": [], "source": [ "import pandas as pd" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Jetzt müssen wir damit beginnen unsere Daten in einem Dictionary zu organisieren. Dabei ist es am einfachsten folgende allgemeine Form einzuhalten:\n", "\n", "* type = 'choropleth',\n", "* locations = Liste der Staaten\n", "* locationmode = 'USA-states'\n", "* colorscale= \n", "\n", "Mit entweder einer vordefinierten Farbskala:\n", "\n", " 'pairs' | 'Greys' | 'Greens' | 'Bluered' | 'Hot' | 'Picnic' | 'Portland' | 'Jet' | 'RdBu' | 'Blackbody' | 'Earth' | 'Electric' | 'YIOrRd' | 'YIGnBu'\n", " \n", "oder einer selbsterstellten [Farbgebung](https://plot.ly/python/heatmap-and-contour-colorscales/).\n", "\n", "* text= Liste oder Array des Textes der für jeden Punkt angezeigt wird\n", "* z= Array der Werte auf der Z-Achse (Farbe)\n", "* colorbar = {'title':'Farbindex Titel'})\n", "\n", "Hier ein einfaches Beispiel:" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": true }, "outputs": [], "source": [ "data = dict(type = 'choropleth',\n", " locations = ['AZ','CA','NY'],\n", " locationmode = 'USA-states',\n", " colorscale= 'Portland',\n", " text= ['text1','text2','text3'],\n", " z=[1.0,2.0,3.0],\n", " colorbar = {'title':'Colorbar Title'})" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Als nächstes erstellen wir ein Dictionary in der Variablen `layout`:" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "collapsed": true }, "outputs": [], "source": [ "layout = dict(geo = {'scope':'usa'})" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Anschließend nutzen wir:\n", "\n", " go.Figure(data = [data],layout = layout)\n", " \n", "um das Objekt zu erstellen, dass wir dann an `iplot()` übergeben." ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "collapsed": true }, "outputs": [], "source": [ "choromap = go.Figure(data = [data],layout = layout)" ] }, { "cell_type": "code", "execution_count": 7, "metadata": { "collapsed": false }, "outputs": [ { "data": { "application/vnd.plotly.v1+json": { "data": [ { "colorbar": { "title": "Colorbar Title" }, "colorscale": "Portland", "locationmode": "USA-states", "locations": [ "AZ", "CA", "NY" ], "text": [ "text1", "text2", "text3" ], "type": "choropleth", "z": [ 1, 2, 3 ] } ], "layout": { "geo": { "scope": "usa" } } }, "text/html": [ "
" ], "text/vnd.plotly.v1+html": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "iplot(choromap)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Karte der USA mit echten Daten\n", "Jetzt können wir uns ein Beispiel mit tatsächlichen Daten und weiteren Optionen anschauen. Dazu verwenden wir einen Datensatz zu landwirtschaftlichen (en. agriculture) Erzeugnissen der USA. Schauen wir sie uns zunächst genauer an:" ] }, { "cell_type": "code", "execution_count": 8, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
codestatecategorytotal exportsbeefporkpoultrydairyfruits freshfruits proctotal fruitsveggies freshveggies proctotal veggiescornwheatcottontext
0ALAlabamastate1390.6334.410.6481.04.068.017.125.115.58.914.3334.970.0317.61Alabama<br>Beef 34.4 Dairy 4.06<br>Fruits 25.1...
1AKAlaskastate13.310.20.10.00.190.00.00.000.61.01.560.00.00.00Alaska<br>Beef 0.2 Dairy 0.19<br>Fruits 0.0 Ve...
2AZArizonastate1463.1771.317.90.0105.4819.341.060.27147.5239.4386.917.348.7423.95Arizona<br>Beef 71.3 Dairy 105.48<br>Fruits 60...
3ARArkansasstate3586.0253.229.4562.93.532.24.76.884.47.111.4569.5114.5665.44Arkansas<br>Beef 53.2 Dairy 3.53<br>Fruits 6.8...
4CACaliforniastate16472.88228.711.1225.4929.952791.85944.68736.40803.21303.52106.7934.6249.31064.95California<br>Beef 228.7 Dairy 929.95<br>Frui...
\n", "
" ], "text/plain": [ " code state category total exports beef pork poultry dairy \\\n", "0 AL Alabama state 1390.63 34.4 10.6 481.0 4.06 \n", "1 AK Alaska state 13.31 0.2 0.1 0.0 0.19 \n", "2 AZ Arizona state 1463.17 71.3 17.9 0.0 105.48 \n", "3 AR Arkansas state 3586.02 53.2 29.4 562.9 3.53 \n", "4 CA California state 16472.88 228.7 11.1 225.4 929.95 \n", "\n", " fruits fresh fruits proc total fruits veggies fresh veggies proc \\\n", "0 8.0 17.1 25.11 5.5 8.9 \n", "1 0.0 0.0 0.00 0.6 1.0 \n", "2 19.3 41.0 60.27 147.5 239.4 \n", "3 2.2 4.7 6.88 4.4 7.1 \n", "4 2791.8 5944.6 8736.40 803.2 1303.5 \n", "\n", " total veggies corn wheat cotton \\\n", "0 14.33 34.9 70.0 317.61 \n", "1 1.56 0.0 0.0 0.00 \n", "2 386.91 7.3 48.7 423.95 \n", "3 11.45 69.5 114.5 665.44 \n", "4 2106.79 34.6 249.3 1064.95 \n", "\n", " text \n", "0 Alabama
Beef 34.4 Dairy 4.06
Fruits 25.1... \n", "1 Alaska
Beef 0.2 Dairy 0.19
Fruits 0.0 Ve... \n", "2 Arizona
Beef 71.3 Dairy 105.48
Fruits 60... \n", "3 Arkansas
Beef 53.2 Dairy 3.53
Fruits 6.8... \n", "4 California
Beef 228.7 Dairy 929.95
Frui... " ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df = pd.read_csv('2011_US_AGRI_Exports')\n", "df.head()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Jetzt können wir davon ausgehend unser Daten-Dictionary für die Flächenkarte aufbauen:" ] }, { "cell_type": "code", "execution_count": 9, "metadata": { "collapsed": true }, "outputs": [], "source": [ "data = dict(type='choropleth',\n", " colorscale = 'YIOrRd',\n", " locations = df['code'],\n", " z = df['total exports'],\n", " locationmode = 'USA-states',\n", " text = df['text'],\n", " marker = dict(line = dict(color = 'rgb(255,255,255)',width = 2)),\n", " colorbar = {'title':\"Millionen USD\"}\n", " ) " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Und unserem Layout können wir weitere Optionen verleihen:" ] }, { "cell_type": "code", "execution_count": 10, "metadata": { "collapsed": true }, "outputs": [], "source": [ "layout = dict(title = '2011 US Landwirtschaftliche Exporte nach Staaten',\n", " geo = dict(scope='usa',\n", " showlakes = True,\n", " lakecolor = 'rgb(85,173,240)')\n", " )" ] }, { "cell_type": "code", "execution_count": 11, "metadata": { "collapsed": true }, "outputs": [], "source": [ "choromap = go.Figure(data = [data],layout = layout)" ] }, { "cell_type": "code", "execution_count": 12, "metadata": { "collapsed": false }, "outputs": [ { "data": { "application/vnd.plotly.v1+json": { "data": [ { "colorbar": { "title": "Millionen USD" }, "colorscale": "YIOrRd", "locationmode": "USA-states", "locations": [ "AL", "AK", "AZ", "AR", "CA", "CO", "CT", "DE", "FL", "GA", "HI", "ID", "IL", "IN", "IA", "KS", "KY", "LA", "ME", "MD", "MA", "MI", "MN", "MS", "MO", "MT", "NE", "NV", "NH", "NJ", "NM", "NY", "NC", "ND", "OH", "OK", "OR", "PA", "RI", "SC", "SD", "TN", "TX", "UT", "VT", "VA", "WA", "WV", "WI", "WY" ], "marker": { "line": { "color": "rgb(255,255,255)", "width": 2 } }, "text": [ "Alabama
Beef 34.4 Dairy 4.06
Fruits 25.11 Veggies 14.33
Wheat 70.0 Corn 34.9", "Alaska
Beef 0.2 Dairy 0.19
Fruits 0.0 Veggies 1.56
Wheat 0.0 Corn 0.0", "Arizona
Beef 71.3 Dairy 105.48
Fruits 60.27 Veggies 386.91
Wheat 48.7 Corn 7.3", "Arkansas
Beef 53.2 Dairy 3.53
Fruits 6.88 Veggies 11.45
Wheat 114.5 Corn 69.5", " California
Beef 228.7 Dairy 929.95
Fruits 8736.4 Veggies 2106.79
Wheat 249.3 Corn 34.6", "Colorado
Beef 261.4 Dairy 71.94
Fruits 17.99 Veggies 118.27
Wheat 400.5 Corn 183.2", "Connecticut
Beef 1.1 Dairy 9.49
Fruits 13.1 Veggies 11.16
Wheat 0.0 Corn 0.0", "Delaware
Beef 0.4 Dairy 2.3
Fruits 1.53 Veggies 20.03
Wheat 22.9 Corn 26.9", "Florida
Beef 42.6 Dairy 66.31
Fruits 1371.36 Veggies 450.86
Wheat 1.8 Corn 3.5", "Georgia
Beef 31.0 Dairy 38.38
Fruits 233.51 Veggies 154.77
Wheat 65.4 Corn 57.8", "Hawaii
Beef 4.0 Dairy 1.16
Fruits 55.51 Veggies 24.83
Wheat 0.0 Corn 0.0", "Idaho
Beef 119.8 Dairy 294.6
Fruits 21.64 Veggies 319.19
Wheat 568.2 Corn 24.0", "Illinois
Beef 53.7 Dairy 45.82
Fruits 12.53 Veggies 39.95
Wheat 223.8 Corn 2228.5", "Indiana
Beef 21.9 Dairy 89.7
Fruits 12.98 Veggies 37.89
Wheat 114.0 Corn 1123.2", "Iowa
Beef 289.8 Dairy 107.0
Fruits 3.24 Veggies 7.1
Wheat 3.1 Corn 2529.8", "Kansas
Beef 659.3 Dairy 65.45
Fruits 3.11 Veggies 9.32
Wheat 1426.5 Corn 457.3", "Kentucky
Beef 54.8 Dairy 28.27
Fruits 6.6 Veggies 0.0
Wheat 149.3 Corn 179.1", "Louisiana
Beef 19.8 Dairy 6.02
Fruits 17.83 Veggies 17.25
Wheat 78.7 Corn 91.4", "Maine
Beef 1.4 Dairy 16.18
Fruits 52.01 Veggies 62.9
Wheat 0.0 Corn 0.0", "Maryland
Beef 5.6 Dairy 24.81
Fruits 12.9 Veggies 20.43
Wheat 55.8 Corn 54.1", "Massachusetts
Beef 0.6 Dairy 5.81
Fruits 80.83 Veggies 21.13
Wheat 0.0 Corn 0.0", "Michigan
Beef 37.7 Dairy 214.82
Fruits 257.69 Veggies 189.96
Wheat 247.0 Corn 381.5", "Minnesota
Beef 112.3 Dairy 218.05
Fruits 7.91 Veggies 120.37
Wheat 538.1 Corn 1264.3", "Mississippi
Beef 12.8 Dairy 5.45
Fruits 17.04 Veggies 27.87
Wheat 102.2 Corn 110.0", "Missouri
Beef 137.2 Dairy 34.26
Fruits 13.18 Veggies 17.9
Wheat 161.7 Corn 428.8", "Montana
Beef 105.0 Dairy 6.82
Fruits 3.3 Veggies 45.27
Wheat 1198.1 Corn 5.4", "Nebraska
Beef 762.2 Dairy 30.07
Fruits 2.16 Veggies 53.5
Wheat 292.3 Corn 1735.9", "Nevada
Beef 21.8 Dairy 16.57
Fruits 1.19 Veggies 27.93
Wheat 5.4 Corn 0.0", "New Hampshire
Beef 0.6 Dairy 7.46
Fruits 7.98 Veggies 4.5
Wheat 0.0 Corn 0.0", "New Jersey
Beef 0.8 Dairy 3.37
Fruits 109.45 Veggies 56.54
Wheat 6.7 Corn 10.1", "New Mexico
Beef 117.2 Dairy 191.01
Fruits 101.9 Veggies 43.88
Wheat 13.9 Corn 11.2", "New York
Beef 22.2 Dairy 331.8
Fruits 202.56 Veggies 143.37
Wheat 29.9 Corn 106.1", "North Carolina
Beef 24.8 Dairy 24.9
Fruits 74.47 Veggies 150.45
Wheat 200.3 Corn 92.2", "North Dakota
Beef 78.5 Dairy 8.14
Fruits 0.25 Veggies 130.79
Wheat 1664.5 Corn 236.1", "Ohio
Beef 36.2 Dairy 134.57
Fruits 27.21 Veggies 53.53
Wheat 207.4 Corn 535.1", "Oklahoma
Beef 337.6 Dairy 24.35
Fruits 9.24 Veggies 8.9
Wheat 324.8 Corn 27.5", "Oregon
Beef 58.8 Dairy 63.66
Fruits 315.04 Veggies 126.5
Wheat 320.3 Corn 11.7", "Pennsylvania
Beef 50.9 Dairy 280.87
Fruits 89.48 Veggies 38.26
Wheat 41.0 Corn 112.1", "Rhode Island
Beef 0.1 Dairy 0.52
Fruits 2.83 Veggies 3.02
Wheat 0.0 Corn 0.0", "South Carolina
Beef 15.2 Dairy 7.62
Fruits 53.45 Veggies 42.66
Wheat 55.3 Corn 32.1", "South Dakota
Beef 193.5 Dairy 46.77
Fruits 0.8 Veggies 4.06
Wheat 704.5 Corn 643.6", "Tennessee
Beef 51.1 Dairy 21.18
Fruits 6.23 Veggies 24.67
Wheat 100.0 Corn 88.8", "Texas
Beef 961.0 Dairy 240.55
Fruits 99.9 Veggies 115.23
Wheat 309.7 Corn 167.2", "Utah
Beef 27.9 Dairy 48.6
Fruits 12.34 Veggies 6.6
Wheat 42.8 Corn 5.3", "Vermont
Beef 6.2 Dairy 65.98
Fruits 8.01 Veggies 4.05
Wheat 0.0 Corn 0.0", "Virginia
Beef 39.5 Dairy 47.85
Fruits 36.48 Veggies 27.25
Wheat 77.5 Corn 39.5", "Washington
Beef 59.2 Dairy 154.18
Fruits 1738.57 Veggies 363.79
Wheat 786.3 Corn 29.5", "West Virginia
Beef 12.0 Dairy 3.9
Fruits 11.54 Veggies 0.0
Wheat 1.6 Corn 3.5", "Wisconsin
Beef 107.3 Dairy 633.6
Fruits 133.8 Veggies 148.99
Wheat 96.7 Corn 460.5", "Wyoming
Beef 75.1 Dairy 2.89
Fruits 0.17 Veggies 10.23
Wheat 20.7 Corn 9.0" ], "type": "choropleth", "z": [ 1390.63, 13.31, 1463.17, 3586.02, 16472.88, 1851.33, 259.62, 282.19, 3764.09, 2860.84, 401.84, 2078.89, 8709.48, 5050.23, 11273.76, 4589.01, 1889.15, 1914.23, 278.37, 692.75, 248.65, 3164.16, 7192.33, 2170.8, 3933.42, 1718, 7114.13, 139.89, 73.06, 500.4, 751.58, 1488.9, 3806.05, 3761.96, 3979.79, 1646.41, 1794.57, 1969.87, 31.59, 929.93, 3770.19, 1535.13, 6648.22, 453.39, 180.14, 1146.48, 3894.81, 138.89, 3090.23, 349.69 ] } ], "layout": { "geo": { "lakecolor": "rgb(85,173,240)", "scope": "usa", "showlakes": true }, "title": "2011 US Landwirtschaftliche Exporte nach Staaten" } }, "text/html": [ "
" ], "text/vnd.plotly.v1+html": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "iplot(choromap)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Flächenkarte der Welt\n", "Betrachten wir als nächstes ein Beispiel mit einer Flächenkarte der Welt:" ] }, { "cell_type": "code", "execution_count": 13, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
COUNTRYGDP (BILLIONS)CODE
0Afghanistan21.71AFG
1Albania13.40ALB
2Algeria227.80DZA
3American Samoa0.75ASM
4Andorra4.80AND
\n", "
" ], "text/plain": [ " COUNTRY GDP (BILLIONS) CODE\n", "0 Afghanistan 21.71 AFG\n", "1 Albania 13.40 ALB\n", "2 Algeria 227.80 DZA\n", "3 American Samoa 0.75 ASM\n", "4 Andorra 4.80 AND" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df = pd.read_csv('2014_World_GDP')\n", "df.head()" ] }, { "cell_type": "code", "execution_count": 14, "metadata": { "collapsed": true }, "outputs": [], "source": [ "data = dict(\n", " type = 'choropleth',\n", " locations = df['CODE'],\n", " z = df['GDP (BILLIONS)'],\n", " text = df['COUNTRY'],\n", " colorbar = {'title' : 'GDP Milliarden USD'},\n", " ) " ] }, { "cell_type": "code", "execution_count": 15, "metadata": { "collapsed": true }, "outputs": [], "source": [ "layout = dict(\n", " title = '2014 Globales GDP',\n", " geo = dict(\n", " showframe = False,\n", " projection = {'type':'Mercator'}\n", " )\n", ")" ] }, { "cell_type": "code", "execution_count": 16, "metadata": { "collapsed": false }, "outputs": [ { "data": { "application/vnd.plotly.v1+json": { "data": [ { "colorbar": { "title": "GDP Milliarden USD" }, "locations": [ "AFG", "ALB", "DZA", "ASM", "AND", "AGO", "AIA", "ATG", "ARG", "ARM", "ABW", "AUS", "AUT", "AZE", "BHM", "BHR", "BGD", "BRB", "BLR", "BEL", "BLZ", "BEN", "BMU", "BTN", "BOL", "BIH", "BWA", "BRA", "VGB", "BRN", "BGR", "BFA", "MMR", "BDI", "CPV", "KHM", "CMR", "CAN", "CYM", "CAF", "TCD", "CHL", "CHN", "COL", "COM", "COD", "COG", "COK", "CRI", "CIV", "HRV", "CUB", "CUW", "CYP", "CZE", "DNK", "DJI", "DMA", "DOM", "ECU", "EGY", "SLV", "GNQ", "ERI", "EST", "ETH", "FLK", "FRO", "FJI", "FIN", "FRA", "PYF", "GAB", "GMB", "GEO", "DEU", "GHA", "GIB", "GRC", "GRL", "GRD", "GUM", "GTM", "GGY", "GNB", "GIN", "GUY", "HTI", "HND", "HKG", "HUN", "ISL", "IND", "IDN", "IRN", "IRQ", "IRL", "IMN", "ISR", "ITA", "JAM", "JPN", "JEY", "JOR", "KAZ", "KEN", "KIR", "KOR", "PRK", "KSV", "KWT", "KGZ", "LAO", "LVA", "LBN", "LSO", "LBR", "LBY", "LIE", "LTU", "LUX", "MAC", "MKD", "MDG", "MWI", "MYS", "MDV", "MLI", "MLT", "MHL", "MRT", "MUS", "MEX", "FSM", "MDA", "MCO", "MNG", "MNE", "MAR", "MOZ", "NAM", "NPL", "NLD", "NCL", "NZL", "NIC", "NGA", "NER", "NIU", "MNP", "NOR", "OMN", "PAK", "PLW", "PAN", "PNG", "PRY", "PER", "PHL", "POL", "PRT", "PRI", "QAT", "ROU", "RUS", "RWA", "KNA", "LCA", "MAF", "SPM", "VCT", "WSM", "SMR", "STP", "SAU", "SEN", "SRB", "SYC", "SLE", "SGP", "SXM", "SVK", "SVN", "SLB", "SOM", "ZAF", "SSD", "ESP", "LKA", "SDN", "SUR", "SWZ", "SWE", "CHE", "SYR", "TWN", "TJK", "TZA", "THA", "TLS", "TGO", "TON", "TTO", "TUN", "TUR", "TKM", "TUV", "UGA", "UKR", "ARE", "GBR", "USA", "URY", "UZB", "VUT", "VEN", "VNM", "VGB", "WBG", "YEM", "ZMB", "ZWE" ], "text": [ "Afghanistan", "Albania", "Algeria", "American Samoa", "Andorra", "Angola", "Anguilla", "Antigua and Barbuda", "Argentina", "Armenia", "Aruba", "Australia", "Austria", "Azerbaijan", "Bahamas, The", "Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium", "Belize", "Benin", "Bermuda", "Bhutan", "Bolivia", "Bosnia and Herzegovina", "Botswana", "Brazil", "British Virgin Islands", "Brunei", "Bulgaria", "Burkina Faso", "Burma", "Burundi", "Cabo Verde", "Cambodia", "Cameroon", "Canada", "Cayman Islands", "Central African Republic", "Chad", "Chile", "China", "Colombia", "Comoros", "Congo, Democratic Republic of the", "Congo, Republic of the", "Cook Islands", "Costa Rica", "Cote d'Ivoire", "Croatia", "Cuba", "Curacao", "Cyprus", "Czech Republic", "Denmark", "Djibouti", "Dominica", "Dominican Republic", "Ecuador", "Egypt", "El Salvador", "Equatorial Guinea", "Eritrea", "Estonia", "Ethiopia", "Falkland Islands (Islas Malvinas)", "Faroe Islands", "Fiji", "Finland", "France", "French Polynesia", "Gabon", "Gambia, The", "Georgia", "Germany", "Ghana", "Gibraltar", "Greece", "Greenland", "Grenada", "Guam", "Guatemala", "Guernsey", "Guinea-Bissau", "Guinea", "Guyana", "Haiti", "Honduras", "Hong Kong", "Hungary", "Iceland", "India", "Indonesia", "Iran", "Iraq", "Ireland", "Isle of Man", "Israel", "Italy", "Jamaica", "Japan", "Jersey", "Jordan", "Kazakhstan", "Kenya", "Kiribati", "Korea, North", "Korea, South", "Kosovo", "Kuwait", "Kyrgyzstan", "Laos", "Latvia", "Lebanon", "Lesotho", "Liberia", "Libya", "Liechtenstein", "Lithuania", "Luxembourg", "Macau", "Macedonia", "Madagascar", "Malawi", "Malaysia", "Maldives", "Mali", "Malta", "Marshall Islands", "Mauritania", "Mauritius", "Mexico", "Micronesia, Federated States of", "Moldova", "Monaco", "Mongolia", "Montenegro", "Morocco", "Mozambique", "Namibia", "Nepal", "Netherlands", "New Caledonia", "New Zealand", "Nicaragua", "Nigeria", "Niger", "Niue", "Northern Mariana Islands", "Norway", "Oman", "Pakistan", "Palau", "Panama", "Papua New Guinea", "Paraguay", "Peru", "Philippines", "Poland", "Portugal", "Puerto Rico", "Qatar", "Romania", "Russia", "Rwanda", "Saint Kitts and Nevis", "Saint Lucia", "Saint Martin", "Saint Pierre and Miquelon", "Saint Vincent and the Grenadines", "Samoa", "San Marino", "Sao Tome and Principe", "Saudi Arabia", "Senegal", "Serbia", "Seychelles", "Sierra Leone", "Singapore", "Sint Maarten", "Slovakia", "Slovenia", "Solomon Islands", "Somalia", "South Africa", "South Sudan", "Spain", "Sri Lanka", "Sudan", "Suriname", "Swaziland", "Sweden", "Switzerland", "Syria", "Taiwan", "Tajikistan", "Tanzania", "Thailand", "Timor-Leste", "Togo", "Tonga", "Trinidad and Tobago", "Tunisia", "Turkey", "Turkmenistan", "Tuvalu", "Uganda", "Ukraine", "United Arab Emirates", "United Kingdom", "United States", "Uruguay", "Uzbekistan", "Vanuatu", "Venezuela", "Vietnam", "Virgin Islands", "West Bank", "Yemen", "Zambia", "Zimbabwe" ], "type": "choropleth", "z": [ 21.71, 13.4, 227.8, 0.75, 4.8, 131.4, 0.18, 1.24, 536.2, 10.88, 2.52, 1483, 436.1, 77.91, 8.65, 34.05, 186.6, 4.28, 75.25, 527.8, 1.67, 9.24, 5.2, 2.09, 34.08, 19.55, 16.3, 2244, 1.1, 17.43, 55.08, 13.38, 65.29, 3.04, 1.98, 16.9, 32.16, 1794, 2.25, 1.73, 15.84, 264.1, 10360, 400.1, 0.72, 32.67, 14.11, 0.18, 50.46, 33.96, 57.18, 77.15, 5.6, 21.34, 205.6, 347.2, 1.58, 0.51, 64.05, 100.5, 284.9, 25.14, 15.4, 3.87, 26.36, 49.86, 0.16, 2.32, 4.17, 276.3, 2902, 7.15, 20.68, 0.92, 16.13, 3820, 35.48, 1.85, 246.4, 2.16, 0.84, 4.6, 58.3, 2.74, 1.04, 6.77, 3.14, 8.92, 19.37, 292.7, 129.7, 16.2, 2048, 856.1, 402.7, 232.2, 245.8, 4.08, 305, 2129, 13.92, 4770, 5.77, 36.55, 225.6, 62.72, 0.16, 28, 1410, 5.99, 179.3, 7.65, 11.71, 32.82, 47.5, 2.46, 2.07, 49.34, 5.11, 48.72, 63.93, 51.68, 10.92, 11.19, 4.41, 336.9, 2.41, 12.04, 10.57, 0.18, 4.29, 12.72, 1296, 0.34, 7.74, 6.06, 11.73, 4.66, 112.6, 16.59, 13.11, 19.64, 880.4, 11.1, 201, 11.85, 594.3, 8.29, 0.01, 1.23, 511.6, 80.54, 237.5, 0.65, 44.69, 16.1, 31.3, 208.2, 284.6, 552.2, 228.2, 93.52, 212, 199, 2057, 8, 0.81, 1.35, 0.56, 0.22, 0.75, 0.83, 1.86, 0.36, 777.9, 15.88, 42.65, 1.47, 5.41, 307.9, 304.1, 99.75, 49.93, 1.16, 2.37, 341.2, 11.89, 1400, 71.57, 70.03, 5.27, 3.84, 559.1, 679, 64.7, 529.5, 9.16, 36.62, 373.8, 4.51, 4.84, 0.49, 29.63, 49.12, 813.3, 43.5, 0.04, 26.09, 134.9, 416.4, 2848, 17420, 55.6, 63.08, 0.82, 209.2, 187.8, 5.08, 6.64, 45.45, 25.61, 13.74 ] } ], "layout": { "geo": { "projection": { "type": "Mercator" }, "showframe": false }, "title": "2014 Globales GDP" } }, "text/html": [ "
" ], "text/vnd.plotly.v1+html": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "choromap = go.Figure(data = [data],layout = layout)\n", "iplot(choromap)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Gut gemacht!" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.0" } }, "nbformat": 4, "nbformat_minor": 2 }