{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "In this notebook we use the new Sunburst plot by [plotly](http://plot.ly/) to illustrate how the World population\n", "is splitted among regions and countries. The data set illustrated here originates from the\n", "[World Bank](https://data.worldbank.org). This notebook is also a quick demo for the \n", "[world_bank_data](https://github.com/mwouts/world_bank_data/blob/master/README.md) Python package." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/vnd.plotly.v1+html": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "import pandas as pd\n", "import mock\n", "import plotly.offline as offline\n", "import world_bank_data as wb\n", "\n", "try:\n", " # Python 3.6\n", " from urllib.request import urlopen\n", "except ImportError:\n", " # Python 2.7\n", " from urllib import urlopen\n", "\n", "# Only show head and tail of dataframes\n", "pd.set_option('display.max_rows', 6)\n", "\n", "\n", "# Plotly.js in version 1.46.1\n", "def get_latest_plotlyjs(url='https://cdn.plot.ly/plotly-1.46.1.min.js'):\n", " return urlopen(url).read().decode('utf-8')\n", "\n", "\n", "with mock.patch('plotly.offline.offline.get_plotlyjs', get_latest_plotlyjs):\n", " offline.init_notebook_mode()" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "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", "
iso2CodenameregionadminregionincomeLevellendingTypecapitalCitylongitudelatitude
id
ABWAWArubaLatin America & CaribbeanHigh incomeNot classifiedOranjestad-70.016712.5167
AFGAFAfghanistanSouth AsiaSouth AsiaLow incomeIDAKabul69.176134.5228
AFRA9AfricaAggregatesAggregatesAggregatesNaNNaN
..............................
ZAFZASouth AfricaSub-Saharan AfricaSub-Saharan Africa (excluding high income)Upper middle incomeIBRDPretoria28.1871-25.7460
ZMBZMZambiaSub-Saharan AfricaSub-Saharan Africa (excluding high income)Lower middle incomeIDALusaka28.2937-15.3982
ZWEZWZimbabweSub-Saharan AfricaSub-Saharan Africa (excluding high income)Low incomeBlendHarare31.0672-17.8312
\n", "

304 rows × 9 columns

\n", "
" ], "text/plain": [ " iso2Code name region \\\n", "id \n", "ABW AW Aruba Latin America & Caribbean \n", "AFG AF Afghanistan South Asia \n", "AFR A9 Africa Aggregates \n", ".. ... ... ... \n", "ZAF ZA South Africa Sub-Saharan Africa \n", "ZMB ZM Zambia Sub-Saharan Africa \n", "ZWE ZW Zimbabwe Sub-Saharan Africa \n", "\n", " adminregion incomeLevel \\\n", "id \n", "ABW High income \n", "AFG South Asia Low income \n", "AFR Aggregates \n", ".. ... ... \n", "ZAF Sub-Saharan Africa (excluding high income) Upper middle income \n", "ZMB Sub-Saharan Africa (excluding high income) Lower middle income \n", "ZWE Sub-Saharan Africa (excluding high income) Low income \n", "\n", " lendingType capitalCity longitude latitude \n", "id \n", "ABW Not classified Oranjestad -70.0167 12.5167 \n", "AFG IDA Kabul 69.1761 34.5228 \n", "AFR Aggregates NaN NaN \n", ".. ... ... ... ... \n", "ZAF IBRD Pretoria 28.1871 -25.7460 \n", "ZMB IDA Lusaka 28.2937 -15.3982 \n", "ZWE Blend Harare 31.0672 -17.8312 \n", "\n", "[304 rows x 9 columns]" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Countries and associated regions\n", "countries = wb.get_countries()\n", "countries" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Country Series Year\n", "Arab World Population, total 2017 414491886.0\n", "Caribbean small states Population, total 2017 7284294.0\n", "Central Europe and the Baltics Population, total 2017 102727102.0\n", " ... \n", "Yemen, Rep. Population, total 2017 28250420.0\n", "Zambia Population, total 2017 17094130.0\n", "Zimbabwe Population, total 2017 16529904.0\n", "Name: SP.POP.TOTL, Length: 264, dtype: float64" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Population dataset, by the World Bank (most recent value)\n", "population = wb.get_series('SP.POP.TOTL', mrv=1)\n", "population" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Country\n", "ARB 414491886.0\n", "CSS 7284294.0\n", "CEB 102727102.0\n", " ... \n", "YEM 28250420.0\n", "ZMB 17094130.0\n", "ZWE 16529904.0\n", "Name: SP.POP.TOTL, Length: 264, dtype: float64" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Same data set, indexed with the country code\n", "population = wb.get_series('SP.POP.TOTL', id_or_value='id', simplify_index=True, mrv=1)\n", "population" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "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", "
regioncountrypopulation
id
ABWLatin America & CaribbeanAruba105264.0
AFGSouth AsiaAfghanistan35530081.0
AGOSub-Saharan AfricaAngola29784193.0
............
ZAFSub-Saharan AfricaSouth Africa56717156.0
ZMBSub-Saharan AfricaZambia17094130.0
ZWESub-Saharan AfricaZimbabwe16529904.0
\n", "

218 rows × 3 columns

\n", "
" ], "text/plain": [ " region country population\n", "id \n", "ABW Latin America & Caribbean Aruba 105264.0\n", "AFG South Asia Afghanistan 35530081.0\n", "AGO Sub-Saharan Africa Angola 29784193.0\n", ".. ... ... ...\n", "ZAF Sub-Saharan Africa South Africa 56717156.0\n", "ZMB Sub-Saharan Africa Zambia 17094130.0\n", "ZWE Sub-Saharan Africa Zimbabwe 16529904.0\n", "\n", "[218 rows x 3 columns]" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Aggregate region, country and population\n", "df = countries[['region', 'name']].rename(columns={'name': 'country'}).loc[countries.region != 'Aggregates']\n", "df['population'] = population\n", "df" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "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", "
parentslabelsvaluestext
0Latin America & CaribbeanAruba105264.0105,264
1South AsiaAfghanistan35530081.035,530,081
2Sub-Saharan AfricaAngola29784193.029,784,193
...............
223WorldSouth Asia0.01,788,388,852
224WorldSub-Saharan Africa0.01,056,038,890
225World0.07,530,360,149
\n", "

226 rows × 4 columns

\n", "
" ], "text/plain": [ " parents labels values \\\n", "0 Latin America & Caribbean Aruba 105264.0 \n", "1 South Asia Afghanistan 35530081.0 \n", "2 Sub-Saharan Africa Angola 29784193.0 \n", ".. ... ... ... \n", "223 World South Asia 0.0 \n", "224 World Sub-Saharan Africa 0.0 \n", "225 World 0.0 \n", "\n", " text \n", "0 105,264 \n", "1 35,530,081 \n", "2 29,784,193 \n", ".. ... \n", "223 1,788,388,852 \n", "224 1,056,038,890 \n", "225 7,530,360,149 \n", "\n", "[226 rows x 4 columns]" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# The sunburst plot requires weights (values), labels, and parent (region, or World)\n", "# We build the corresponding table here\n", "columns = ['parents', 'labels', 'values']\n", "\n", "level1 = df.copy()\n", "level1.columns = columns\n", "level1['text'] = level1['values'].apply(lambda pop: '{:,.0f}'.format(pop))\n", "\n", "level2 = df.groupby('region').population.sum().reset_index()[['region', 'region', 'population']]\n", "level2.columns = columns\n", "level2['parents'] = 'World'\n", "# move value to text for this level\n", "level2['text'] = level2['values'].apply(lambda pop: '{:,.0f}'.format(pop))\n", "level2['values'] = 0\n", "\n", "level3 = pd.DataFrame({'parents': [''], 'labels': ['World'],\n", " 'values': [0.0], 'text': ['{:,.0f}'.format(population.loc['WLD'])]})\n", "\n", "all_levels = pd.concat([level1, level2, level3], axis=0).reset_index(drop=True)\n", "all_levels" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "application/vnd.plotly.v1+json": { "config": { "linkText": "Export to plot.ly", "plotlyServerURL": "https://plot.ly", "showLink": false }, "data": [ { "hoverinfo": "text", "labels": [ "Aruba", "Afghanistan", "Angola", "Albania", "Andorra", "United Arab Emirates", "Argentina", "Armenia", "American Samoa", "Antigua and Barbuda", "Australia", "Austria", "Azerbaijan", "Burundi", "Belgium", "Benin", "Burkina Faso", "Bangladesh", "Bulgaria", "Bahrain", "Bahamas, The", "Bosnia and Herzegovina", "Belarus", "Belize", "Bermuda", "Bolivia", "Brazil", "Barbados", "Brunei Darussalam", "Bhutan", "Botswana", "Central African Republic", "Canada", "Switzerland", "Channel Islands", "Chile", "China", "Cote d'Ivoire", "Cameroon", "Congo, Dem. Rep.", "Congo, Rep.", "Colombia", "Comoros", "Cabo Verde", "Costa Rica", "Cuba", "Curacao", "Cayman Islands", "Cyprus", "Czech Republic", "Germany", "Djibouti", "Dominica", "Denmark", "Dominican Republic", "Algeria", "Ecuador", "Egypt, Arab Rep.", "Eritrea", "Spain", "Estonia", "Ethiopia", "Finland", "Fiji", "France", "Faroe Islands", "Micronesia, Fed. Sts.", "Gabon", "United Kingdom", "Georgia", "Ghana", "Gibraltar", "Guinea", "Gambia, The", "Guinea-Bissau", "Equatorial Guinea", "Greece", "Grenada", "Greenland", "Guatemala", "Guam", "Guyana", "Hong Kong SAR, China", "Honduras", "Croatia", "Haiti", "Hungary", "Indonesia", "Isle of Man", "India", "Ireland", "Iran, Islamic Rep.", "Iraq", "Iceland", "Israel", "Italy", "Jamaica", "Jordan", "Japan", "Kazakhstan", "Kenya", "Kyrgyz Republic", "Cambodia", "Kiribati", "St. Kitts and Nevis", "Korea, Rep.", "Kuwait", "Lao PDR", "Lebanon", "Liberia", "Libya", "St. Lucia", "Liechtenstein", "Sri Lanka", "Lesotho", "Lithuania", "Luxembourg", "Latvia", "Macao SAR, China", "St. Martin (French part)", "Morocco", "Monaco", "Moldova", "Madagascar", "Maldives", "Mexico", "Marshall Islands", "North Macedonia", "Mali", "Malta", "Myanmar", "Montenegro", "Mongolia", "Northern Mariana Islands", "Mozambique", "Mauritania", "Mauritius", "Malawi", "Malaysia", "Namibia", "New Caledonia", "Niger", "Nigeria", "Nicaragua", "Netherlands", "Norway", "Nepal", "Nauru", "New Zealand", "Oman", "Pakistan", "Panama", "Peru", "Philippines", "Palau", "Papua New Guinea", "Poland", "Puerto Rico", "Korea, Dem. People’s Rep.", "Portugal", "Paraguay", "West Bank and Gaza", "French Polynesia", "Qatar", "Romania", "Russian Federation", "Rwanda", "Saudi Arabia", "Sudan", "Senegal", "Singapore", "Solomon Islands", "Sierra Leone", "El Salvador", "San Marino", "Somalia", "Serbia", "South Sudan", "Sao Tome and Principe", "Suriname", "Slovak Republic", "Slovenia", "Sweden", "Eswatini", "Sint Maarten (Dutch part)", "Seychelles", "Syrian Arab Republic", "Turks and Caicos Islands", "Chad", "Togo", "Thailand", "Tajikistan", "Turkmenistan", "Timor-Leste", "Tonga", "Trinidad and Tobago", "Tunisia", "Turkey", "Tuvalu", "Taiwan, China", "Tanzania", "Uganda", "Ukraine", "Uruguay", "United States", "Uzbekistan", "St. Vincent and the Grenadines", "Venezuela, RB", "British Virgin Islands", "Virgin Islands (U.S.)", "Vietnam", "Vanuatu", "Samoa", "Kosovo", "Yemen, Rep.", "South Africa", "Zambia", "Zimbabwe", "East Asia & Pacific", "Europe & Central Asia", "Latin America & Caribbean ", "Middle East & North Africa", "North America", "South Asia", "Sub-Saharan Africa ", "World" ], "parents": [ "Latin America & Caribbean ", "South Asia", "Sub-Saharan Africa ", "Europe & Central Asia", "Europe & Central Asia", "Middle East & North Africa", "Latin America & Caribbean ", "Europe & Central Asia", "East Asia & Pacific", "Latin America & Caribbean ", "East Asia & Pacific", "Europe & Central Asia", "Europe & Central Asia", "Sub-Saharan Africa ", "Europe & Central Asia", "Sub-Saharan Africa ", "Sub-Saharan Africa ", "South Asia", "Europe & Central Asia", "Middle East & North Africa", "Latin America & Caribbean ", "Europe & Central Asia", "Europe & Central Asia", "Latin America & Caribbean ", "North America", "Latin America & Caribbean ", "Latin America & Caribbean ", "Latin America & Caribbean ", "East Asia & Pacific", "South Asia", "Sub-Saharan Africa ", "Sub-Saharan Africa ", "North America", "Europe & Central Asia", "Europe & Central Asia", "Latin America & Caribbean ", "East Asia & Pacific", "Sub-Saharan Africa ", "Sub-Saharan Africa ", "Sub-Saharan Africa ", "Sub-Saharan Africa ", "Latin America & Caribbean ", "Sub-Saharan Africa ", "Sub-Saharan Africa ", "Latin America & Caribbean ", "Latin America & Caribbean ", "Latin America & Caribbean ", "Latin America & Caribbean ", "Europe & Central Asia", "Europe & Central Asia", "Europe & Central Asia", "Middle East & North Africa", "Latin America & Caribbean ", "Europe & Central Asia", "Latin America & Caribbean ", "Middle East & North Africa", "Latin America & Caribbean ", "Middle East & North Africa", "Sub-Saharan Africa ", "Europe & Central Asia", "Europe & Central Asia", "Sub-Saharan Africa ", "Europe & Central Asia", "East Asia & Pacific", "Europe & Central Asia", "Europe & Central Asia", "East Asia & Pacific", "Sub-Saharan Africa ", "Europe & Central Asia", "Europe & Central Asia", "Sub-Saharan Africa ", "Europe & Central Asia", "Sub-Saharan Africa ", "Sub-Saharan Africa ", "Sub-Saharan Africa ", "Sub-Saharan Africa ", "Europe & Central Asia", "Latin America & Caribbean ", "Europe & Central Asia", "Latin America & Caribbean ", "East Asia & Pacific", "Latin America & Caribbean ", "East Asia & Pacific", "Latin America & Caribbean ", "Europe & Central Asia", "Latin America & Caribbean ", "Europe & Central Asia", "East Asia & Pacific", "Europe & Central Asia", "South Asia", "Europe & Central Asia", "Middle East & North Africa", "Middle East & North Africa", "Europe & Central Asia", "Middle East & North Africa", "Europe & Central Asia", "Latin America & Caribbean ", "Middle East & North Africa", "East Asia & Pacific", "Europe & Central Asia", "Sub-Saharan Africa ", "Europe & Central Asia", "East Asia & Pacific", "East Asia & Pacific", "Latin America & Caribbean ", "East Asia & Pacific", "Middle East & North Africa", "East Asia & Pacific", "Middle East & North Africa", "Sub-Saharan Africa ", "Middle East & North Africa", "Latin America & Caribbean ", "Europe & Central Asia", "South Asia", "Sub-Saharan Africa ", "Europe & Central Asia", "Europe & Central Asia", "Europe & Central Asia", "East Asia & Pacific", "Latin America & Caribbean ", "Middle East & North Africa", "Europe & Central Asia", "Europe & Central Asia", "Sub-Saharan Africa ", "South Asia", "Latin America & Caribbean ", "East Asia & Pacific", "Europe & Central Asia", "Sub-Saharan Africa ", "Middle East & North Africa", "East Asia & Pacific", "Europe & Central Asia", "East Asia & Pacific", "East Asia & Pacific", "Sub-Saharan Africa ", "Sub-Saharan Africa ", "Sub-Saharan Africa ", "Sub-Saharan Africa ", "East Asia & Pacific", "Sub-Saharan Africa ", "East Asia & Pacific", "Sub-Saharan Africa ", "Sub-Saharan Africa ", "Latin America & Caribbean ", "Europe & Central Asia", "Europe & Central Asia", "South Asia", "East Asia & Pacific", "East Asia & Pacific", "Middle East & North Africa", "South Asia", "Latin America & Caribbean ", "Latin America & Caribbean ", "East Asia & Pacific", "East Asia & Pacific", "East Asia & Pacific", "Europe & Central Asia", "Latin America & Caribbean ", "East Asia & Pacific", "Europe & Central Asia", "Latin America & Caribbean ", "Middle East & North Africa", "East Asia & Pacific", "Middle East & North Africa", "Europe & Central Asia", "Europe & Central Asia", "Sub-Saharan Africa ", "Middle East & North Africa", "Sub-Saharan Africa ", "Sub-Saharan Africa ", "East Asia & Pacific", "East Asia & Pacific", "Sub-Saharan Africa ", "Latin America & Caribbean ", "Europe & Central Asia", "Sub-Saharan Africa ", "Europe & Central Asia", "Sub-Saharan Africa ", "Sub-Saharan Africa ", "Latin America & Caribbean ", "Europe & Central Asia", "Europe & Central Asia", "Europe & Central Asia", "Sub-Saharan Africa ", "Latin America & Caribbean ", "Sub-Saharan Africa ", "Middle East & North Africa", "Latin America & Caribbean ", "Sub-Saharan Africa ", "Sub-Saharan Africa ", "East Asia & Pacific", "Europe & Central Asia", "Europe & Central Asia", "East Asia & Pacific", "East Asia & Pacific", "Latin America & Caribbean ", "Middle East & North Africa", "Europe & Central Asia", "East Asia & Pacific", "East Asia & Pacific", "Sub-Saharan Africa ", "Sub-Saharan Africa ", "Europe & Central Asia", "Latin America & Caribbean ", "North America", "Europe & Central Asia", "Latin America & Caribbean ", "Latin America & Caribbean ", "Latin America & Caribbean ", "Latin America & Caribbean ", "East Asia & Pacific", "East Asia & Pacific", "East Asia & Pacific", "Europe & Central Asia", "Middle East & North Africa", "Sub-Saharan Africa ", "Sub-Saharan Africa ", "Sub-Saharan Africa ", "World", "World", "World", "World", "World", "World", "World", "" ], "text": [ "105,264", "35,530,081", "29,784,193", "2,873,457", "76,965", "9,400,145", "44,271,041", "2,930,450", "55,641", "102,012", "24,598,933", "8,809,212", "9,862,429", "10,864,245", "11,372,068", "11,175,692", "19,193,382", "164,669,751", "7,075,991", "1,492,584", "395,361", "3,507,017", "9,507,875", "374,681", "65,441", "11,051,600", "209,288,278", "285,719", "428,697", "807,610", "2,291,661", "4,659,080", "36,708,083", "8,466,017", "165,314", "18,054,726", "1,386,395,000", "24,294,750", "24,053,727", "81,339,988", "5,260,750", "49,065,615", "813,912", "546,388", "4,905,769", "11,484,636", "161,014", "61,559", "1,179,551", "10,591,323", "82,695,000", "956,985", "73,925", "5,769,603", "10,766,998", "41,318,142", "16,624,858", "97,553,151", "nan", "46,572,028", "1,315,480", "104,957,438", "5,511,303", "905,502", "67,118,648", "49,290", "105,544", "2,025,137", "66,022,273", "3,717,100", "28,833,629", "34,571", "12,717,176", "2,100,568", "1,861,283", "1,267,689", "10,760,421", "107,825", "56,171", "16,913,503", "164,229", "777,859", "7,391,700", "9,265,067", "4,125,700", "10,981,229", "9,781,127", "263,991,379", "84,287", "1,339,180,127", "4,813,608", "81,162,788", "38,274,618", "341,284", "8,712,400", "60,551,416", "2,890,299", "9,702,353", "126,785,797", "18,037,646", "49,699,862", "6,201,500", "16,005,373", "116,398", "55,345", "51,466,201", "4,136,528", "6,858,160", "6,082,357", "4,731,906", "6,374,616", "178,844", "37,922", "21,444,000", "2,233,339", "2,827,721", "599,449", "1,940,740", "622,567", "32,125", "35,739,580", "38,695", "3,549,750", "25,570,895", "436,330", "129,163,276", "53,127", "2,083,160", "18,541,980", "465,292", "53,370,609", "622,471", "3,075,647", "55,144", "29,668,834", "4,420,184", "1,264,613", "18,622,104", "31,624,264", "2,533,794", "280,460", "21,477,348", "190,886,311", "6,217,581", "17,132,854", "5,282,223", "29,304,998", "13,649", "4,793,900", "4,636,262", "197,015,955", "4,098,587", "32,165,485", "104,918,090", "21,729", "8,251,162", "37,975,841", "3,337,177", "25,490,965", "10,293,718", "6,811,297", "4,684,777", "283,007", "2,639,211", "19,586,539", "144,495,044", "12,208,407", "32,938,213", "40,533,330", "15,850,567", "5,612,253", "611,343", "7,557,212", "6,377,853", "33,400", "14,742,523", "7,022,268", "12,575,714", "204,327", "563,402", "5,439,892", "2,066,748", "10,067,744", "1,367,254", "41,109", "95,843", "18,269,868", "35,446", "14,899,994", "7,797,694", "69,037,513", "8,921,343", "5,758,075", "1,296,311", "108,020", "1,369,125", "11,532,127", "80,745,020", "11,192", "nan", "57,310,019", "42,862,958", "44,831,159", "3,456,750", "325,719,178", "32,387,200", "109,897", "31,977,065", "31,196", "107,268", "95,540,800", "276,244", "196,440", "1,830,700", "28,250,420", "56,717,156", "17,094,130", "16,529,904", "2,290,812,990", "915,545,801", "644,137,666", "444,322,417", "362,492,702", "1,788,388,852", "1,056,038,890", "7,530,360,149" ], "type": "sunburst", "values": [ 105264, 35530081, 29784193, 2873457, 76965, 9400145, 44271041, 2930450, 55641, 102012, 24598933, 8809212, 9862429, 10864245, 11372068, 11175692, 19193382, 164669751, 7075991, 1492584, 395361, 3507017, 9507875, 374681, 65441, 11051600, 209288278, 285719, 428697, 807610, 2291661, 4659080, 36708083, 8466017, 165314, 18054726, 1386395000, 24294750, 24053727, 81339988, 5260750, 49065615, 813912, 546388, 4905769, 11484636, 161014, 61559, 1179551, 10591323, 82695000, 956985, 73925, 5769603, 10766998, 41318142, 16624858, 97553151, null, 46572028, 1315480, 104957438, 5511303, 905502, 67118648, 49290, 105544, 2025137, 66022273, 3717100, 28833629, 34571, 12717176, 2100568, 1861283, 1267689, 10760421, 107825, 56171, 16913503, 164229, 777859, 7391700, 9265067, 4125700, 10981229, 9781127, 263991379, 84287, 1339180127, 4813608, 81162788, 38274618, 341284, 8712400, 60551416, 2890299, 9702353, 126785797, 18037646, 49699862, 6201500, 16005373, 116398, 55345, 51466201, 4136528, 6858160, 6082357, 4731906, 6374616, 178844, 37922, 21444000, 2233339, 2827721, 599449, 1940740, 622567, 32125, 35739580, 38695, 3549750, 25570895, 436330, 129163276, 53127, 2083160, 18541980, 465292, 53370609, 622471, 3075647, 55144, 29668834, 4420184, 1264613, 18622104, 31624264, 2533794, 280460, 21477348, 190886311, 6217581, 17132854, 5282223, 29304998, 13649, 4793900, 4636262, 197015955, 4098587, 32165485, 104918090, 21729, 8251162, 37975841, 3337177, 25490965, 10293718, 6811297, 4684777, 283007, 2639211, 19586539, 144495044, 12208407, 32938213, 40533330, 15850567, 5612253, 611343, 7557212, 6377853, 33400, 14742523, 7022268, 12575714, 204327, 563402, 5439892, 2066748, 10067744, 1367254, 41109, 95843, 18269868, 35446, 14899994, 7797694, 69037513, 8921343, 5758075, 1296311, 108020, 1369125, 11532127, 80745020, 11192, null, 57310019, 42862958, 44831159, 3456750, 325719178, 32387200, 109897, 31977065, 31196, 107268, 95540800, 276244, 196440, 1830700, 28250420, 56717156, 17094130, 16529904, 0, 0, 0, 0, 0, 0, 0, 0 ] } ], "layout": { "height": 800, "title": "World Population (World Bank, 2017)
Click on a region to zoom", "width": 800 } }, "text/html": [ "
" ], "text/vnd.plotly.v1+html": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "# And now we can plot the World Population\n", "offline.iplot(dict(\n", " data=[dict(type='sunburst', hoverinfo='text', **all_levels)],\n", " layout=dict(title='World Population (World Bank, 2017)
Click on a region to zoom',\n", " width=800, height=800)),\n", " validate=False)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "jupytext": { "formats": "ipynb,py:light" }, "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.7.3" } }, "nbformat": 4, "nbformat_minor": 2 }