{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Creating Sunburst Charts" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Sunburst charts are a hierarchical data visualization technique that displays relationships and proportions within nested categories using concentric circles. Each layer of the chart represents a level in the hierarchy, starting from the center and expanding outward. For instance, in a company structure, the inner circle could represent the organization as a whole, the next layer the departments, and subsequent layers the teams or individual roles within those departments. The size of each segment typically corresponds to a numerical value, such as revenue or population, making it easy to compare proportions within and across different categories.\n", "\n", "Sunburst charts are particularly useful for visualizing hierarchical data with many layers and showcasing the composition of categories within a whole. They are effective in situations where relationships and proportions at multiple levels need to be understood simultaneously, such as organizational structures, file system breakdowns, or market share by product lines and subcategories. Their circular layout makes efficient use of space and can visually engage an audience, making them a great choice for storytelling and presentations.\n", "\n", "However, sunburst charts should be avoided when the hierarchy is too deep or the data is too detailed, as this can lead to visual clutter and make the chart difficult to interpret. Additionally, they are not ideal for datasets requiring precise comparisons between categories, as the curved segments can distort perception compared to linear representations. In such cases, alternative visualizations like tree maps or bar charts may be more effective. The key is to use sunburst charts when the hierarchical structure and overall proportions are the primary focus, rather than specific quantitative analysis." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Getting ready" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "For this recipe we will create two data sets. The fist one `df1` contains data representing personal goals falling in different categories. While the second one `df2` is an extract from the `Gapminder` data set" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import pandas as pd" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "df1 = pd.DataFrame(dict(Activity=[\"My Goals\", \"Health\", \"Career\", \"Personal\", \"Finance\", \n", " \"Exercise\", \"Diet\", \"Sleep\", \n", " \"New Skills\", \"Networking\", \n", " \"Family\", \"Friends\", \n", " \"Investing\", \"Saving\"\n", " ],\n", " Category=[\"\", \"My Goals\", \"My Goals\", \"My Goals\", \"My Goals\", \"Health\", \"Health\", \"Health\", \"Career\", \"Career\", \"Personal\", \"Personal\", \"Finance\", \"Finance\"],\n", " Value=[0, 25, 25, 25, 25, 10, 10, 10, 10, 10, 10, 10, 10, 10]))" ] }, { "cell_type": "code", "execution_count": 3, "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", "
ActivityCategoryValue
0My Goals0
1HealthMy Goals25
2CareerMy Goals25
3PersonalMy Goals25
4FinanceMy Goals25
\n", "
" ], "text/plain": [ " Activity Category Value\n", "0 My Goals 0\n", "1 Health My Goals 25\n", "2 Career My Goals 25\n", "3 Personal My Goals 25\n", "4 Finance My Goals 25" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df1.head()" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "import plotly.express as px" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "df2 = px.data.gapminder().query(\"year == 2007\")" ] }, { "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", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
countrycontinentyearlifeExppopgdpPercapiso_alphaiso_num
11AfghanistanAsia200743.82831889923974.580338AFG4
23AlbaniaEurope200776.42336005235937.029526ALB8
35AlgeriaAfrica200772.301333332166223.367465DZA12
47AngolaAfrica200742.731124204764797.231267AGO24
59ArgentinaAmericas200775.3204030192712779.379640ARG32
\n", "
" ], "text/plain": [ " country continent year lifeExp pop gdpPercap iso_alpha \\\n", "11 Afghanistan Asia 2007 43.828 31889923 974.580338 AFG \n", "23 Albania Europe 2007 76.423 3600523 5937.029526 ALB \n", "35 Algeria Africa 2007 72.301 33333216 6223.367465 DZA \n", "47 Angola Africa 2007 42.731 12420476 4797.231267 AGO \n", "59 Argentina Americas 2007 75.320 40301927 12779.379640 ARG \n", "\n", " iso_num \n", "11 4 \n", "23 8 \n", "35 12 \n", "47 24 \n", "59 32 " ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df2.head()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## How to do it" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "1. Import the `plotly.express` module as `px`" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [], "source": [ "import plotly.express as px" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "2. Create a minimal sunburst chart by calling the function `sunburst` from Plotly express and passing the data set `df1` as well as the following key arguments:\n", "\n", "- `names`\n", "- `parents`\n", "\n", "\n", "In addition, the following extra arguments are specified\n", "\n", "- `height` and `width`\n", "- `title`" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "application/vnd.plotly.v1+json": { "config": { "plotlyServerURL": "https://plot.ly" }, "data": [ { "domain": { "x": [ 0, 1 ], "y": [ 0, 1 ] }, "hovertemplate": "Activity=%{label}
Category=%{parent}", "labels": [ "My Goals", "Health", "Career", "Personal", "Finance", "Exercise", "Diet", "Sleep", "New Skills", "Networking", "Family", "Friends", "Investing", "Saving" ], "name": "", "parents": [ "", "My Goals", "My Goals", "My Goals", "My Goals", "Health", "Health", "Health", "Career", "Career", "Personal", "Personal", "Finance", "Finance" ], "type": "sunburst" } ], "layout": { "height": 600, "legend": { "tracegroupgap": 0 }, "template": { "data": { "bar": [ { "error_x": { "color": "#2a3f5f" }, "error_y": { "color": "#2a3f5f" }, "marker": { "line": { "color": "#E5ECF6", "width": 0.5 }, "pattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 } }, "type": "bar" } ], "barpolar": [ { "marker": { "line": { "color": "#E5ECF6", "width": 0.5 }, "pattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 } }, "type": "barpolar" } ], "carpet": [ { "aaxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "baxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "type": "carpet" } ], "choropleth": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "choropleth" } ], "contour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "contour" } ], "contourcarpet": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "contourcarpet" } ], "heatmap": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmap" } ], "heatmapgl": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmapgl" } ], "histogram": [ { "marker": { "pattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 } }, "type": "histogram" } ], "histogram2d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2d" } ], "histogram2dcontour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2dcontour" } ], "mesh3d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "mesh3d" } ], "parcoords": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "parcoords" } ], "pie": [ { "automargin": true, "type": "pie" } ], "scatter": [ { "fillpattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 }, "type": "scatter" } ], "scatter3d": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter3d" } ], "scattercarpet": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattercarpet" } ], "scattergeo": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergeo" } ], "scattergl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergl" } ], "scattermapbox": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattermapbox" } ], "scatterpolar": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolar" } ], "scatterpolargl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolargl" } ], "scatterternary": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterternary" } ], "surface": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "surface" } ], "table": [ { "cells": { "fill": { "color": "#EBF0F8" }, "line": { "color": "white" } }, "header": { "fill": { "color": "#C8D4E3" }, "line": { "color": "white" } }, "type": "table" } ] }, "layout": { "annotationdefaults": { "arrowcolor": "#2a3f5f", "arrowhead": 0, "arrowwidth": 1 }, "autotypenumbers": "strict", "coloraxis": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "colorscale": { "diverging": [ [ 0, "#8e0152" ], [ 0.1, "#c51b7d" ], [ 0.2, "#de77ae" ], [ 0.3, "#f1b6da" ], [ 0.4, "#fde0ef" ], [ 0.5, "#f7f7f7" ], [ 0.6, "#e6f5d0" ], [ 0.7, "#b8e186" ], [ 0.8, "#7fbc41" ], [ 0.9, "#4d9221" ], [ 1, "#276419" ] ], "sequential": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "sequentialminus": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ] }, "colorway": [ "#636efa", "#EF553B", "#00cc96", "#ab63fa", "#FFA15A", "#19d3f3", "#FF6692", "#B6E880", "#FF97FF", "#FECB52" ], "font": { "color": "#2a3f5f" }, "geo": { "bgcolor": "white", "lakecolor": "white", "landcolor": "#E5ECF6", "showlakes": true, "showland": true, "subunitcolor": "white" }, "hoverlabel": { "align": "left" }, "hovermode": "closest", "mapbox": { "style": "light" }, "paper_bgcolor": "white", "plot_bgcolor": "#E5ECF6", "polar": { "angularaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "radialaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "scene": { "xaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "yaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "zaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" } }, "shapedefaults": { "line": { "color": "#2a3f5f" } }, "ternary": { "aaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "baxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "caxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "title": { "x": 0.05 }, "xaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 }, "yaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 } } }, "title": { "text": "Personal Goals 2025" }, "width": 900 } } }, "metadata": {}, "output_type": "display_data" } ], "source": [ "fig = px.sunburst(df1, names='Activity', parents='Category', \n", " height=600, width=900,\n", " title='Personal Goals 2025')\n", "fig.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "3. Customise the colors used in the scatter by using the input `color_discrete_sequence`" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "application/vnd.plotly.v1+json": { "config": { "plotlyServerURL": "https://plot.ly" }, "data": [ { "domain": { "x": [ 0, 1 ], "y": [ 0, 1 ] }, "hovertemplate": "Activity=%{label}
Category=%{parent}", "labels": [ "My Goals", "Health", "Career", "Personal", "Finance", "Exercise", "Diet", "Sleep", "New Skills", "Networking", "Family", "Friends", "Investing", "Saving" ], "name": "", "parents": [ "", "My Goals", "My Goals", "My Goals", "My Goals", "Health", "Health", "Health", "Career", "Career", "Personal", "Personal", "Finance", "Finance" ], "type": "sunburst" } ], "layout": { "height": 600, "legend": { "tracegroupgap": 0 }, "sunburstcolorway": [ "rgb(253, 253, 204)", "rgb(206, 236, 179)", "rgb(156, 219, 165)", "rgb(111, 201, 163)", "rgb(86, 177, 163)", "rgb(76, 153, 160)", "rgb(68, 130, 155)", "rgb(62, 108, 150)", "rgb(62, 82, 143)", "rgb(64, 60, 115)", "rgb(54, 43, 77)", "rgb(39, 26, 44)" ], "template": { "data": { "bar": [ { "error_x": { "color": "#2a3f5f" }, "error_y": { "color": "#2a3f5f" }, "marker": { "line": { "color": "#E5ECF6", "width": 0.5 }, "pattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 } }, "type": "bar" } ], "barpolar": [ { "marker": { "line": { "color": "#E5ECF6", "width": 0.5 }, "pattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 } }, "type": "barpolar" } ], "carpet": [ { "aaxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "baxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "type": "carpet" } ], "choropleth": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "choropleth" } ], "contour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "contour" } ], "contourcarpet": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "contourcarpet" } ], "heatmap": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmap" } ], "heatmapgl": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmapgl" } ], "histogram": [ { "marker": { "pattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 } }, "type": "histogram" } ], "histogram2d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2d" } ], "histogram2dcontour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2dcontour" } ], "mesh3d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "mesh3d" } ], "parcoords": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "parcoords" } ], "pie": [ { "automargin": true, "type": "pie" } ], "scatter": [ { "fillpattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 }, "type": "scatter" } ], "scatter3d": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter3d" } ], "scattercarpet": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattercarpet" } ], "scattergeo": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergeo" } ], "scattergl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergl" } ], "scattermapbox": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattermapbox" } ], "scatterpolar": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolar" } ], "scatterpolargl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolargl" } ], "scatterternary": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterternary" } ], "surface": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "surface" } ], "table": [ { "cells": { "fill": { "color": "#EBF0F8" }, "line": { "color": "white" } }, "header": { "fill": { "color": "#C8D4E3" }, "line": { "color": "white" } }, "type": "table" } ] }, "layout": { "annotationdefaults": { "arrowcolor": "#2a3f5f", "arrowhead": 0, "arrowwidth": 1 }, "autotypenumbers": "strict", "coloraxis": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "colorscale": { "diverging": [ [ 0, "#8e0152" ], [ 0.1, "#c51b7d" ], [ 0.2, "#de77ae" ], [ 0.3, "#f1b6da" ], [ 0.4, "#fde0ef" ], [ 0.5, "#f7f7f7" ], [ 0.6, "#e6f5d0" ], [ 0.7, "#b8e186" ], [ 0.8, "#7fbc41" ], [ 0.9, "#4d9221" ], [ 1, "#276419" ] ], "sequential": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "sequentialminus": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ] }, "colorway": [ "#636efa", "#EF553B", "#00cc96", "#ab63fa", "#FFA15A", "#19d3f3", "#FF6692", "#B6E880", "#FF97FF", "#FECB52" ], "font": { "color": "#2a3f5f" }, "geo": { "bgcolor": "white", "lakecolor": "white", "landcolor": "#E5ECF6", "showlakes": true, "showland": true, "subunitcolor": "white" }, "hoverlabel": { "align": "left" }, "hovermode": "closest", "mapbox": { "style": "light" }, "paper_bgcolor": "white", "plot_bgcolor": "#E5ECF6", "polar": { "angularaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "radialaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "scene": { "xaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "yaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "zaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" } }, "shapedefaults": { "line": { "color": "#2a3f5f" } }, "ternary": { "aaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "baxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "caxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "title": { "x": 0.05 }, "xaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 }, "yaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 } } }, "title": { "text": "Personal Goals 2025" }, "width": 900 } } }, "metadata": {}, "output_type": "display_data" } ], "source": [ "fig = px.sunburst(df1, names='Activity', parents='Category', \n", " color_discrete_sequence=px.colors.sequential.deep,\n", " height=600, width=900,\n", " title='Personal Goals 2025')\n", "fig.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "4. Customise the data to appear in the hover tooltip by specifying the arguments `hover_name` and `hover_data`" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "application/vnd.plotly.v1+json": { "config": { "plotlyServerURL": "https://plot.ly" }, "data": [ { "customdata": [ [ "My Goals", "" ], [ "Health", "My Goals" ], [ "Career", "My Goals" ], [ "Personal", "My Goals" ], [ "Finance", "My Goals" ], [ "Exercise", "Health" ], [ "Diet", "Health" ], [ "Sleep", "Health" ], [ "New Skills", "Career" ], [ "Networking", "Career" ], [ "Family", "Personal" ], [ "Friends", "Personal" ], [ "Investing", "Finance" ], [ "Saving", "Finance" ] ], "domain": { "x": [ 0, 1 ], "y": [ 0, 1 ] }, "hovertemplate": "%{hovertext}

Activity=%{customdata[0]}", "hovertext": [ "", "My Goals", "My Goals", "My Goals", "My Goals", "Health", "Health", "Health", "Career", "Career", "Personal", "Personal", "Finance", "Finance" ], "labels": [ "My Goals", "Health", "Career", "Personal", "Finance", "Exercise", "Diet", "Sleep", "New Skills", "Networking", "Family", "Friends", "Investing", "Saving" ], "name": "", "parents": [ "", "My Goals", "My Goals", "My Goals", "My Goals", "Health", "Health", "Health", "Career", "Career", "Personal", "Personal", "Finance", "Finance" ], "type": "sunburst" } ], "layout": { "height": 600, "legend": { "tracegroupgap": 0 }, "sunburstcolorway": [ "rgb(253, 253, 204)", "rgb(206, 236, 179)", "rgb(156, 219, 165)", "rgb(111, 201, 163)", "rgb(86, 177, 163)", "rgb(76, 153, 160)", "rgb(68, 130, 155)", "rgb(62, 108, 150)", "rgb(62, 82, 143)", "rgb(64, 60, 115)", "rgb(54, 43, 77)", "rgb(39, 26, 44)" ], "template": { "data": { "bar": [ { "error_x": { "color": "#2a3f5f" }, "error_y": { "color": "#2a3f5f" }, "marker": { "line": { "color": "#E5ECF6", "width": 0.5 }, "pattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 } }, "type": "bar" } ], "barpolar": [ { "marker": { "line": { "color": "#E5ECF6", "width": 0.5 }, "pattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 } }, "type": "barpolar" } ], "carpet": [ { "aaxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "baxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "type": "carpet" } ], "choropleth": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "choropleth" } ], "contour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "contour" } ], "contourcarpet": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "contourcarpet" } ], "heatmap": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmap" } ], "heatmapgl": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmapgl" } ], "histogram": [ { "marker": { "pattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 } }, "type": "histogram" } ], "histogram2d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2d" } ], "histogram2dcontour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2dcontour" } ], "mesh3d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "mesh3d" } ], "parcoords": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "parcoords" } ], "pie": [ { "automargin": true, "type": "pie" } ], "scatter": [ { "fillpattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 }, "type": "scatter" } ], "scatter3d": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter3d" } ], "scattercarpet": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattercarpet" } ], "scattergeo": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergeo" } ], "scattergl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergl" } ], "scattermapbox": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattermapbox" } ], "scatterpolar": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolar" } ], "scatterpolargl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolargl" } ], "scatterternary": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterternary" } ], "surface": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "surface" } ], "table": [ { "cells": { "fill": { "color": "#EBF0F8" }, "line": { "color": "white" } }, "header": { "fill": { "color": "#C8D4E3" }, "line": { "color": "white" } }, "type": "table" } ] }, "layout": { "annotationdefaults": { "arrowcolor": "#2a3f5f", "arrowhead": 0, "arrowwidth": 1 }, "autotypenumbers": "strict", "coloraxis": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "colorscale": { "diverging": [ [ 0, "#8e0152" ], [ 0.1, "#c51b7d" ], [ 0.2, "#de77ae" ], [ 0.3, "#f1b6da" ], [ 0.4, "#fde0ef" ], [ 0.5, "#f7f7f7" ], [ 0.6, "#e6f5d0" ], [ 0.7, "#b8e186" ], [ 0.8, "#7fbc41" ], [ 0.9, "#4d9221" ], [ 1, "#276419" ] ], "sequential": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "sequentialminus": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ] }, "colorway": [ "#636efa", "#EF553B", "#00cc96", "#ab63fa", "#FFA15A", "#19d3f3", "#FF6692", "#B6E880", "#FF97FF", "#FECB52" ], "font": { "color": "#2a3f5f" }, "geo": { "bgcolor": "white", "lakecolor": "white", "landcolor": "#E5ECF6", "showlakes": true, "showland": true, "subunitcolor": "white" }, "hoverlabel": { "align": "left" }, "hovermode": "closest", "mapbox": { "style": "light" }, "paper_bgcolor": "white", "plot_bgcolor": "#E5ECF6", "polar": { "angularaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "radialaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "scene": { "xaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "yaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "zaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" } }, "shapedefaults": { "line": { "color": "#2a3f5f" } }, "ternary": { "aaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "baxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "caxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "title": { "x": 0.05 }, "xaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 }, "yaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 } } }, "title": { "text": "Personal Goals 2025" }, "width": 900 } } }, "metadata": {}, "output_type": "display_data" } ], "source": [ "fig = px.sunburst(df1, names='Activity', parents='Category', \n", " color_discrete_sequence=px.colors.sequential.deep,\n", " hover_name='Category',\n", " hover_data={'Activity':True, 'Category': False},\n", " height=600, width=900,\n", " title='Personal Goals 2025')\n", "fig.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "For our second example, we are going to use the second data set `df2` which contains a subset of the `Gapminder` data. The idea is to visualise both Population size and Life Expectancy in the world with particular interest on the comparison between regions.\n", "\n", "1. Create an sunburst chart using the function `sunburst` and passing the arguments\n", "\n", " - `path`: this represents the list of columns names or columns of a rectangular dataframe defining the hierarchy of sectors, from root to leaves (groing from the center outwards). In this case, we pass the list `['continent', 'country']` since we want to be able to visualise the data by regions\n", " - `values`: this is the name of the column (alternatively, you can pass an array object) that is used to specify the size of the wedges which form the Sunburst chart. In our case we pass `pop` since we want to visualise the population size" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "data": { "application/vnd.plotly.v1+json": { "config": { "plotlyServerURL": "https://plot.ly" }, "data": [ { "branchvalues": "total", "domain": { "x": [ 0, 1 ], "y": [ 0, 1 ] }, "hovertemplate": "labels=%{label}
pop=%{value}
parent=%{parent}
id=%{id}", "ids": [ "Asia/Afghanistan", "Europe/Albania", "Africa/Algeria", "Africa/Angola", "Americas/Argentina", "Oceania/Australia", "Europe/Austria", "Asia/Bahrain", "Asia/Bangladesh", "Europe/Belgium", "Africa/Benin", "Americas/Bolivia", "Europe/Bosnia and Herzegovina", "Africa/Botswana", "Americas/Brazil", "Europe/Bulgaria", "Africa/Burkina Faso", "Africa/Burundi", "Asia/Cambodia", "Africa/Cameroon", "Americas/Canada", "Africa/Central African Republic", "Africa/Chad", "Americas/Chile", "Asia/China", "Americas/Colombia", "Africa/Comoros", "Africa/Congo, Dem. Rep.", "Africa/Congo, Rep.", "Americas/Costa Rica", "Africa/Cote d'Ivoire", "Europe/Croatia", "Americas/Cuba", "Europe/Czech Republic", "Europe/Denmark", "Africa/Djibouti", "Americas/Dominican Republic", "Americas/Ecuador", "Africa/Egypt", "Americas/El Salvador", "Africa/Equatorial Guinea", "Africa/Eritrea", "Africa/Ethiopia", "Europe/Finland", "Europe/France", "Africa/Gabon", "Africa/Gambia", "Europe/Germany", "Africa/Ghana", "Europe/Greece", "Americas/Guatemala", "Africa/Guinea", "Africa/Guinea-Bissau", "Americas/Haiti", "Americas/Honduras", "Asia/Hong Kong, China", "Europe/Hungary", "Europe/Iceland", "Asia/India", "Asia/Indonesia", "Asia/Iran", "Asia/Iraq", "Europe/Ireland", "Asia/Israel", "Europe/Italy", "Americas/Jamaica", "Asia/Japan", "Asia/Jordan", "Africa/Kenya", "Asia/Korea, Dem. Rep.", "Asia/Korea, Rep.", "Asia/Kuwait", "Asia/Lebanon", "Africa/Lesotho", "Africa/Liberia", "Africa/Libya", "Africa/Madagascar", "Africa/Malawi", "Asia/Malaysia", "Africa/Mali", "Africa/Mauritania", "Africa/Mauritius", "Americas/Mexico", "Asia/Mongolia", "Europe/Montenegro", "Africa/Morocco", "Africa/Mozambique", "Asia/Myanmar", "Africa/Namibia", "Asia/Nepal", "Europe/Netherlands", "Oceania/New Zealand", "Americas/Nicaragua", "Africa/Niger", "Africa/Nigeria", "Europe/Norway", "Asia/Oman", "Asia/Pakistan", "Americas/Panama", "Americas/Paraguay", "Americas/Peru", "Asia/Philippines", "Europe/Poland", "Europe/Portugal", "Americas/Puerto Rico", "Africa/Reunion", "Europe/Romania", "Africa/Rwanda", "Africa/Sao Tome and Principe", "Asia/Saudi Arabia", "Africa/Senegal", "Europe/Serbia", "Africa/Sierra Leone", "Asia/Singapore", "Europe/Slovak Republic", "Europe/Slovenia", "Africa/Somalia", "Africa/South Africa", "Europe/Spain", "Asia/Sri Lanka", "Africa/Sudan", "Africa/Swaziland", "Europe/Sweden", "Europe/Switzerland", "Asia/Syria", "Asia/Taiwan", "Africa/Tanzania", "Asia/Thailand", "Africa/Togo", "Americas/Trinidad and Tobago", "Africa/Tunisia", "Europe/Turkey", "Africa/Uganda", "Europe/United Kingdom", "Americas/United States", "Americas/Uruguay", "Americas/Venezuela", "Asia/Vietnam", "Asia/West Bank and Gaza", "Asia/Yemen, Rep.", "Africa/Zambia", "Africa/Zimbabwe", "Africa", "Americas", "Asia", "Europe", "Oceania" ], "labels": [ "Afghanistan", "Albania", "Algeria", "Angola", "Argentina", "Australia", "Austria", "Bahrain", "Bangladesh", "Belgium", "Benin", "Bolivia", "Bosnia and Herzegovina", "Botswana", "Brazil", "Bulgaria", "Burkina Faso", "Burundi", "Cambodia", "Cameroon", "Canada", "Central African Republic", "Chad", "Chile", "China", "Colombia", "Comoros", "Congo, Dem. Rep.", "Congo, Rep.", "Costa Rica", "Cote d'Ivoire", "Croatia", "Cuba", "Czech Republic", "Denmark", "Djibouti", "Dominican Republic", "Ecuador", "Egypt", "El Salvador", "Equatorial Guinea", "Eritrea", "Ethiopia", "Finland", "France", "Gabon", "Gambia", "Germany", "Ghana", "Greece", "Guatemala", "Guinea", "Guinea-Bissau", "Haiti", "Honduras", "Hong Kong, China", "Hungary", "Iceland", "India", "Indonesia", "Iran", "Iraq", "Ireland", "Israel", "Italy", "Jamaica", "Japan", "Jordan", "Kenya", "Korea, Dem. Rep.", "Korea, Rep.", "Kuwait", "Lebanon", "Lesotho", "Liberia", "Libya", "Madagascar", "Malawi", "Malaysia", "Mali", "Mauritania", "Mauritius", "Mexico", "Mongolia", "Montenegro", "Morocco", "Mozambique", "Myanmar", "Namibia", "Nepal", "Netherlands", "New Zealand", "Nicaragua", "Niger", "Nigeria", "Norway", "Oman", "Pakistan", "Panama", "Paraguay", "Peru", "Philippines", "Poland", "Portugal", "Puerto Rico", "Reunion", "Romania", "Rwanda", "Sao Tome and Principe", "Saudi Arabia", "Senegal", "Serbia", "Sierra Leone", "Singapore", "Slovak Republic", "Slovenia", "Somalia", "South Africa", "Spain", "Sri Lanka", "Sudan", "Swaziland", "Sweden", "Switzerland", "Syria", "Taiwan", "Tanzania", "Thailand", "Togo", "Trinidad and Tobago", "Tunisia", "Turkey", "Uganda", "United Kingdom", "United States", "Uruguay", "Venezuela", "Vietnam", "West Bank and Gaza", "Yemen, Rep.", "Zambia", "Zimbabwe", "Africa", "Americas", "Asia", "Europe", "Oceania" ], "name": "", "parents": [ "Asia", "Europe", "Africa", "Africa", "Americas", "Oceania", "Europe", "Asia", "Asia", "Europe", "Africa", "Americas", "Europe", "Africa", "Americas", "Europe", "Africa", "Africa", "Asia", "Africa", "Americas", "Africa", "Africa", "Americas", "Asia", "Americas", "Africa", "Africa", "Africa", "Americas", "Africa", "Europe", "Americas", "Europe", "Europe", "Africa", "Americas", "Americas", "Africa", "Americas", "Africa", "Africa", "Africa", "Europe", "Europe", "Africa", "Africa", "Europe", "Africa", "Europe", "Americas", "Africa", "Africa", "Americas", "Americas", "Asia", "Europe", "Europe", "Asia", "Asia", "Asia", "Asia", "Europe", "Asia", "Europe", "Americas", "Asia", "Asia", "Africa", "Asia", "Asia", "Asia", "Asia", "Africa", "Africa", "Africa", "Africa", "Africa", "Asia", "Africa", "Africa", "Africa", "Americas", "Asia", "Europe", "Africa", "Africa", "Asia", "Africa", "Asia", "Europe", "Oceania", "Americas", "Africa", "Africa", "Europe", "Asia", "Asia", "Americas", "Americas", "Americas", "Asia", "Europe", "Europe", "Americas", "Africa", "Europe", "Africa", "Africa", "Asia", "Africa", "Europe", "Africa", "Asia", "Europe", "Europe", "Africa", "Africa", "Europe", "Asia", "Africa", "Africa", "Europe", "Europe", "Asia", "Asia", "Africa", "Asia", "Africa", "Americas", "Africa", "Europe", "Africa", "Europe", "Americas", "Americas", "Americas", "Asia", "Asia", "Asia", "Africa", "Africa", "", "", "", "", "" ], "type": "sunburst", "values": [ 31889923, 3600523, 33333216, 12420476, 40301927, 20434176, 8199783, 708573, 150448339, 10392226, 8078314, 9119152, 4552198, 1639131, 190010647, 7322858, 14326203, 8390505, 14131858, 17696293, 33390141, 4369038, 10238807, 16284741, 1318683096, 44227550, 710960, 64606759, 3800610, 4133884, 18013409, 4493312, 11416987, 10228744, 5468120, 496374, 9319622, 13755680, 80264543, 6939688, 551201, 4906585, 76511887, 5238460, 61083916, 1454867, 1688359, 82400996, 22873338, 10706290, 12572928, 9947814, 1472041, 8502814, 7483763, 6980412, 9956108, 301931, 1110396331, 223547000, 69453570, 27499638, 4109086, 6426679, 58147733, 2780132, 127467972, 6053193, 35610177, 23301725, 49044790, 2505559, 3921278, 2012649, 3193942, 6036914, 19167654, 13327079, 24821286, 12031795, 3270065, 1250882, 108700891, 2874127, 684736, 33757175, 19951656, 47761980, 2055080, 28901790, 16570613, 4115771, 5675356, 12894865, 135031164, 4627926, 3204897, 169270617, 3242173, 6667147, 28674757, 91077287, 38518241, 10642836, 3942491, 798094, 22276056, 8860588, 199579, 27601038, 12267493, 10150265, 6144562, 4553009, 5447502, 2009245, 9118773, 43997828, 40448191, 20378239, 42292929, 1133066, 9031088, 7554661, 19314747, 23174294, 38139640, 65068149, 5701579, 1056608, 10276158, 71158647, 29170398, 60776238, 301139947, 3447496, 26084662, 85262356, 4018332, 22211743, 11746035, 12311143, 929539692, 898871184, 3811953827, 586098529, 24549947 ] } ], "layout": { "height": 600, "legend": { "tracegroupgap": 0 }, "template": { "data": { "bar": [ { "error_x": { "color": "#2a3f5f" }, "error_y": { "color": "#2a3f5f" }, "marker": { "line": { "color": "#E5ECF6", "width": 0.5 }, "pattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 } }, "type": "bar" } ], "barpolar": [ { "marker": { "line": { "color": "#E5ECF6", "width": 0.5 }, "pattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 } }, "type": "barpolar" } ], "carpet": [ { "aaxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "baxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "type": "carpet" } ], "choropleth": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "choropleth" } ], "contour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "contour" } ], "contourcarpet": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "contourcarpet" } ], "heatmap": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmap" } ], "heatmapgl": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmapgl" } ], "histogram": [ { "marker": { "pattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 } }, "type": "histogram" } ], "histogram2d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2d" } ], "histogram2dcontour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2dcontour" } ], "mesh3d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "mesh3d" } ], "parcoords": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "parcoords" } ], "pie": [ { "automargin": true, "type": "pie" } ], "scatter": [ { "fillpattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 }, "type": "scatter" } ], "scatter3d": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter3d" } ], "scattercarpet": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattercarpet" } ], "scattergeo": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergeo" } ], "scattergl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergl" } ], "scattermapbox": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattermapbox" } ], "scatterpolar": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolar" } ], "scatterpolargl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolargl" } ], "scatterternary": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterternary" } ], "surface": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "surface" } ], "table": [ { "cells": { "fill": { "color": "#EBF0F8" }, "line": { "color": "white" } }, "header": { "fill": { "color": "#C8D4E3" }, "line": { "color": "white" } }, "type": "table" } ] }, "layout": { "annotationdefaults": { "arrowcolor": "#2a3f5f", "arrowhead": 0, "arrowwidth": 1 }, "autotypenumbers": "strict", "coloraxis": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "colorscale": { "diverging": [ [ 0, "#8e0152" ], [ 0.1, "#c51b7d" ], [ 0.2, "#de77ae" ], [ 0.3, "#f1b6da" ], [ 0.4, "#fde0ef" ], [ 0.5, "#f7f7f7" ], [ 0.6, "#e6f5d0" ], [ 0.7, "#b8e186" ], [ 0.8, "#7fbc41" ], [ 0.9, "#4d9221" ], [ 1, "#276419" ] ], "sequential": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "sequentialminus": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ] }, "colorway": [ "#636efa", "#EF553B", "#00cc96", "#ab63fa", "#FFA15A", "#19d3f3", "#FF6692", "#B6E880", "#FF97FF", "#FECB52" ], "font": { "color": "#2a3f5f" }, "geo": { "bgcolor": "white", "lakecolor": "white", "landcolor": "#E5ECF6", "showlakes": true, "showland": true, "subunitcolor": "white" }, "hoverlabel": { "align": "left" }, "hovermode": "closest", "mapbox": { "style": "light" }, "paper_bgcolor": "white", "plot_bgcolor": "#E5ECF6", "polar": { "angularaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "radialaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "scene": { "xaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "yaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "zaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" } }, "shapedefaults": { "line": { "color": "#2a3f5f" } }, "ternary": { "aaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "baxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "caxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "title": { "x": 0.05 }, "xaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 }, "yaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 } } }, "title": { "text": "Life Expectancy accross Regions in 2007" }, "width": 900 } } }, "metadata": {}, "output_type": "display_data" } ], "source": [ "fig = px.sunburst(df2, \n", " path=['continent', 'country'], \n", " values='pop',\n", " height=600, width=900,\n", " title='Life Expectancy accross Regions in 2007'\n", " )\n", "fig.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "2. Use the argument `color` to add an extra dimension to the data through the color of the wedges. In this case, we are going to associate the color of each wedge with the Life expectancy of the corresponding country or region. So, we set `color='lifeExp'`. We also use the argument `color_continuous_scale` to set the color palette to be used" ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [ { "data": { "application/vnd.plotly.v1+json": { "config": { "plotlyServerURL": "https://plot.ly" }, "data": [ { "branchvalues": "total", "customdata": [ [ 43.828 ], [ 76.423 ], [ 72.301 ], [ 42.731 ], [ 75.32 ], [ 81.235 ], [ 79.829 ], [ 75.635 ], [ 64.062 ], [ 79.441 ], [ 56.728 ], [ 65.554 ], [ 74.852 ], [ 50.728 ], [ 72.39 ], [ 73.005 ], [ 52.295 ], [ 49.58 ], [ 59.723 ], [ 50.43 ], [ 80.65300000000002 ], [ 44.74100000000001 ], [ 50.651 ], [ 78.553 ], [ 72.961 ], [ 72.889 ], [ 65.152 ], [ 46.462 ], [ 55.322 ], [ 78.782 ], [ 48.328 ], [ 75.748 ], [ 78.273 ], [ 76.486 ], [ 78.332 ], [ 54.791 ], [ 72.235 ], [ 74.994 ], [ 71.33800000000002 ], [ 71.878 ], [ 51.57899999999999 ], [ 58.03999999999999 ], [ 52.947 ], [ 79.313 ], [ 80.65699999999998 ], [ 56.73500000000001 ], [ 59.448 ], [ 79.406 ], [ 60.02199999999999 ], [ 79.483 ], [ 70.259 ], [ 56.007 ], [ 46.38800000000001 ], [ 60.916 ], [ 70.19800000000001 ], [ 82.208 ], [ 73.33800000000002 ], [ 81.757 ], [ 64.69800000000001 ], [ 70.65 ], [ 70.964 ], [ 59.545 ], [ 78.885 ], [ 80.745 ], [ 80.546 ], [ 72.567 ], [ 82.603 ], [ 72.535 ], [ 54.11 ], [ 67.297 ], [ 78.623 ], [ 77.58800000000002 ], [ 71.993 ], [ 42.592 ], [ 45.678 ], [ 73.952 ], [ 59.443000000000005 ], [ 48.303 ], [ 74.241 ], [ 54.467 ], [ 64.164 ], [ 72.801 ], [ 76.195 ], [ 66.803 ], [ 74.543 ], [ 71.164 ], [ 42.082 ], [ 62.06900000000001 ], [ 52.90600000000001 ], [ 63.785 ], [ 79.762 ], [ 80.204 ], [ 72.899 ], [ 56.867 ], [ 46.859 ], [ 80.196 ], [ 75.64 ], [ 65.483 ], [ 75.53699999999998 ], [ 71.752 ], [ 71.421 ], [ 71.688 ], [ 75.563 ], [ 78.098 ], [ 78.74600000000002 ], [ 76.442 ], [ 72.476 ], [ 46.242 ], [ 65.528 ], [ 72.777 ], [ 63.062 ], [ 74.002 ], [ 42.56800000000001 ], [ 79.972 ], [ 74.663 ], [ 77.926 ], [ 48.159 ], [ 49.339 ], [ 80.941 ], [ 72.396 ], [ 58.55599999999999 ], [ 39.613 ], [ 80.884 ], [ 81.70100000000002 ], [ 74.143 ], [ 78.4 ], [ 52.517 ], [ 70.616 ], [ 58.42 ], [ 69.819 ], [ 73.923 ], [ 71.777 ], [ 51.542 ], [ 79.425 ], [ 78.242 ], [ 76.384 ], [ 73.747 ], [ 74.249 ], [ 73.422 ], [ 62.698 ], [ 42.38399999999999 ], [ 43.487 ], [ 54.56441057558197 ], [ 75.35668222743027 ], [ 69.44386304205017 ], [ 77.89057081069897 ], [ 81.06215400970112 ] ], "domain": { "x": [ 0, 1 ], "y": [ 0, 1 ] }, "hovertemplate": "labels=%{label}
pop=%{value}
parent=%{parent}
id=%{id}
lifeExp=%{color}", "ids": [ "Asia/Afghanistan", "Europe/Albania", "Africa/Algeria", "Africa/Angola", "Americas/Argentina", "Oceania/Australia", "Europe/Austria", "Asia/Bahrain", "Asia/Bangladesh", "Europe/Belgium", "Africa/Benin", "Americas/Bolivia", "Europe/Bosnia and Herzegovina", "Africa/Botswana", "Americas/Brazil", "Europe/Bulgaria", "Africa/Burkina Faso", "Africa/Burundi", "Asia/Cambodia", "Africa/Cameroon", "Americas/Canada", "Africa/Central African Republic", "Africa/Chad", "Americas/Chile", "Asia/China", "Americas/Colombia", "Africa/Comoros", "Africa/Congo, Dem. Rep.", "Africa/Congo, Rep.", "Americas/Costa Rica", "Africa/Cote d'Ivoire", "Europe/Croatia", "Americas/Cuba", "Europe/Czech Republic", "Europe/Denmark", "Africa/Djibouti", "Americas/Dominican Republic", "Americas/Ecuador", "Africa/Egypt", "Americas/El Salvador", "Africa/Equatorial Guinea", "Africa/Eritrea", "Africa/Ethiopia", "Europe/Finland", "Europe/France", "Africa/Gabon", "Africa/Gambia", "Europe/Germany", "Africa/Ghana", "Europe/Greece", "Americas/Guatemala", "Africa/Guinea", "Africa/Guinea-Bissau", "Americas/Haiti", "Americas/Honduras", "Asia/Hong Kong, China", "Europe/Hungary", "Europe/Iceland", "Asia/India", "Asia/Indonesia", "Asia/Iran", "Asia/Iraq", "Europe/Ireland", "Asia/Israel", "Europe/Italy", "Americas/Jamaica", "Asia/Japan", "Asia/Jordan", "Africa/Kenya", "Asia/Korea, Dem. Rep.", "Asia/Korea, Rep.", "Asia/Kuwait", "Asia/Lebanon", "Africa/Lesotho", "Africa/Liberia", "Africa/Libya", "Africa/Madagascar", "Africa/Malawi", "Asia/Malaysia", "Africa/Mali", "Africa/Mauritania", "Africa/Mauritius", "Americas/Mexico", "Asia/Mongolia", "Europe/Montenegro", "Africa/Morocco", "Africa/Mozambique", "Asia/Myanmar", "Africa/Namibia", "Asia/Nepal", "Europe/Netherlands", "Oceania/New Zealand", "Americas/Nicaragua", "Africa/Niger", "Africa/Nigeria", "Europe/Norway", "Asia/Oman", "Asia/Pakistan", "Americas/Panama", "Americas/Paraguay", "Americas/Peru", "Asia/Philippines", "Europe/Poland", "Europe/Portugal", "Americas/Puerto Rico", "Africa/Reunion", "Europe/Romania", "Africa/Rwanda", "Africa/Sao Tome and Principe", "Asia/Saudi Arabia", "Africa/Senegal", "Europe/Serbia", "Africa/Sierra Leone", "Asia/Singapore", "Europe/Slovak Republic", "Europe/Slovenia", "Africa/Somalia", "Africa/South Africa", "Europe/Spain", "Asia/Sri Lanka", "Africa/Sudan", "Africa/Swaziland", "Europe/Sweden", "Europe/Switzerland", "Asia/Syria", "Asia/Taiwan", "Africa/Tanzania", "Asia/Thailand", "Africa/Togo", "Americas/Trinidad and Tobago", "Africa/Tunisia", "Europe/Turkey", "Africa/Uganda", "Europe/United Kingdom", "Americas/United States", "Americas/Uruguay", "Americas/Venezuela", "Asia/Vietnam", "Asia/West Bank and Gaza", "Asia/Yemen, Rep.", "Africa/Zambia", "Africa/Zimbabwe", "Africa", "Americas", "Asia", "Europe", "Oceania" ], "labels": [ "Afghanistan", "Albania", "Algeria", "Angola", "Argentina", "Australia", "Austria", "Bahrain", "Bangladesh", "Belgium", "Benin", "Bolivia", "Bosnia and Herzegovina", "Botswana", "Brazil", "Bulgaria", "Burkina Faso", "Burundi", "Cambodia", "Cameroon", "Canada", "Central African Republic", "Chad", "Chile", "China", "Colombia", "Comoros", "Congo, Dem. Rep.", "Congo, Rep.", "Costa Rica", "Cote d'Ivoire", "Croatia", "Cuba", "Czech Republic", "Denmark", "Djibouti", "Dominican Republic", "Ecuador", "Egypt", "El Salvador", "Equatorial Guinea", "Eritrea", "Ethiopia", "Finland", "France", "Gabon", "Gambia", "Germany", "Ghana", "Greece", "Guatemala", "Guinea", "Guinea-Bissau", "Haiti", "Honduras", "Hong Kong, China", "Hungary", "Iceland", "India", "Indonesia", "Iran", "Iraq", "Ireland", "Israel", "Italy", "Jamaica", "Japan", "Jordan", "Kenya", "Korea, Dem. Rep.", "Korea, Rep.", "Kuwait", "Lebanon", "Lesotho", "Liberia", "Libya", "Madagascar", "Malawi", "Malaysia", "Mali", "Mauritania", "Mauritius", "Mexico", "Mongolia", "Montenegro", "Morocco", "Mozambique", "Myanmar", "Namibia", "Nepal", "Netherlands", "New Zealand", "Nicaragua", "Niger", "Nigeria", "Norway", "Oman", "Pakistan", "Panama", "Paraguay", "Peru", "Philippines", "Poland", "Portugal", "Puerto Rico", "Reunion", "Romania", "Rwanda", "Sao Tome and Principe", "Saudi Arabia", "Senegal", "Serbia", "Sierra Leone", "Singapore", "Slovak Republic", "Slovenia", "Somalia", "South Africa", "Spain", "Sri Lanka", "Sudan", "Swaziland", "Sweden", "Switzerland", "Syria", "Taiwan", "Tanzania", "Thailand", "Togo", "Trinidad and Tobago", "Tunisia", "Turkey", "Uganda", "United Kingdom", "United States", "Uruguay", "Venezuela", "Vietnam", "West Bank and Gaza", "Yemen, Rep.", "Zambia", "Zimbabwe", "Africa", "Americas", "Asia", "Europe", "Oceania" ], "marker": { "coloraxis": "coloraxis", "colors": [ 43.828, 76.423, 72.301, 42.731, 75.32, 81.235, 79.829, 75.635, 64.062, 79.441, 56.728, 65.554, 74.852, 50.728, 72.39, 73.005, 52.295, 49.58, 59.723, 50.43, 80.65300000000002, 44.74100000000001, 50.651, 78.553, 72.961, 72.889, 65.152, 46.462, 55.322, 78.782, 48.328, 75.748, 78.273, 76.486, 78.332, 54.791, 72.235, 74.994, 71.33800000000002, 71.878, 51.57899999999999, 58.03999999999999, 52.947, 79.313, 80.65699999999998, 56.73500000000001, 59.448, 79.406, 60.02199999999999, 79.483, 70.259, 56.007, 46.38800000000001, 60.916, 70.19800000000001, 82.208, 73.33800000000002, 81.757, 64.69800000000001, 70.65, 70.964, 59.545, 78.885, 80.745, 80.546, 72.567, 82.603, 72.535, 54.11, 67.297, 78.623, 77.58800000000002, 71.993, 42.592, 45.678, 73.952, 59.443000000000005, 48.303, 74.241, 54.467, 64.164, 72.801, 76.195, 66.803, 74.543, 71.164, 42.082, 62.06900000000001, 52.90600000000001, 63.785, 79.762, 80.204, 72.899, 56.867, 46.859, 80.196, 75.64, 65.483, 75.53699999999998, 71.752, 71.421, 71.688, 75.563, 78.098, 78.74600000000002, 76.442, 72.476, 46.242, 65.528, 72.777, 63.062, 74.002, 42.56800000000001, 79.972, 74.663, 77.926, 48.159, 49.339, 80.941, 72.396, 58.55599999999999, 39.613, 80.884, 81.70100000000002, 74.143, 78.4, 52.517, 70.616, 58.42, 69.819, 73.923, 71.777, 51.542, 79.425, 78.242, 76.384, 73.747, 74.249, 73.422, 62.698, 42.38399999999999, 43.487, 54.56441057558197, 75.35668222743027, 69.44386304205017, 77.89057081069897, 81.06215400970112 ] }, "name": "", "parents": [ "Asia", "Europe", "Africa", "Africa", "Americas", "Oceania", "Europe", "Asia", "Asia", "Europe", "Africa", "Americas", "Europe", "Africa", "Americas", "Europe", "Africa", "Africa", "Asia", "Africa", "Americas", "Africa", "Africa", "Americas", "Asia", "Americas", "Africa", "Africa", "Africa", "Americas", "Africa", "Europe", "Americas", "Europe", "Europe", "Africa", "Americas", "Americas", "Africa", "Americas", "Africa", "Africa", "Africa", "Europe", "Europe", "Africa", "Africa", "Europe", "Africa", "Europe", "Americas", "Africa", "Africa", "Americas", "Americas", "Asia", "Europe", "Europe", "Asia", "Asia", "Asia", "Asia", "Europe", "Asia", "Europe", "Americas", "Asia", "Asia", "Africa", "Asia", "Asia", "Asia", "Asia", "Africa", "Africa", "Africa", "Africa", "Africa", "Asia", "Africa", "Africa", "Africa", "Americas", "Asia", "Europe", "Africa", "Africa", "Asia", "Africa", "Asia", "Europe", "Oceania", "Americas", "Africa", "Africa", "Europe", "Asia", "Asia", "Americas", "Americas", "Americas", "Asia", "Europe", "Europe", "Americas", "Africa", "Europe", "Africa", "Africa", "Asia", "Africa", "Europe", "Africa", "Asia", "Europe", "Europe", "Africa", "Africa", "Europe", "Asia", "Africa", "Africa", "Europe", "Europe", "Asia", "Asia", "Africa", "Asia", "Africa", "Americas", "Africa", "Europe", "Africa", "Europe", "Americas", "Americas", "Americas", "Asia", "Asia", "Asia", "Africa", "Africa", "", "", "", "", "" ], "type": "sunburst", "values": [ 31889923, 3600523, 33333216, 12420476, 40301927, 20434176, 8199783, 708573, 150448339, 10392226, 8078314, 9119152, 4552198, 1639131, 190010647, 7322858, 14326203, 8390505, 14131858, 17696293, 33390141, 4369038, 10238807, 16284741, 1318683096, 44227550, 710960, 64606759, 3800610, 4133884, 18013409, 4493312, 11416987, 10228744, 5468120, 496374, 9319622, 13755680, 80264543, 6939688, 551201, 4906585, 76511887, 5238460, 61083916, 1454867, 1688359, 82400996, 22873338, 10706290, 12572928, 9947814, 1472041, 8502814, 7483763, 6980412, 9956108, 301931, 1110396331, 223547000, 69453570, 27499638, 4109086, 6426679, 58147733, 2780132, 127467972, 6053193, 35610177, 23301725, 49044790, 2505559, 3921278, 2012649, 3193942, 6036914, 19167654, 13327079, 24821286, 12031795, 3270065, 1250882, 108700891, 2874127, 684736, 33757175, 19951656, 47761980, 2055080, 28901790, 16570613, 4115771, 5675356, 12894865, 135031164, 4627926, 3204897, 169270617, 3242173, 6667147, 28674757, 91077287, 38518241, 10642836, 3942491, 798094, 22276056, 8860588, 199579, 27601038, 12267493, 10150265, 6144562, 4553009, 5447502, 2009245, 9118773, 43997828, 40448191, 20378239, 42292929, 1133066, 9031088, 7554661, 19314747, 23174294, 38139640, 65068149, 5701579, 1056608, 10276158, 71158647, 29170398, 60776238, 301139947, 3447496, 26084662, 85262356, 4018332, 22211743, 11746035, 12311143, 929539692, 898871184, 3811953827, 586098529, 24549947 ] } ], "layout": { "coloraxis": { "colorbar": { "title": { "text": "lifeExp" } }, "colorscale": [ [ 0, "rgb(103,0,31)" ], [ 0.1, "rgb(178,24,43)" ], [ 0.2, "rgb(214,96,77)" ], [ 0.3, "rgb(244,165,130)" ], [ 0.4, "rgb(253,219,199)" ], [ 0.5, "rgb(247,247,247)" ], [ 0.6, "rgb(209,229,240)" ], [ 0.7, "rgb(146,197,222)" ], [ 0.8, "rgb(67,147,195)" ], [ 0.9, "rgb(33,102,172)" ], [ 1, "rgb(5,48,97)" ] ] }, "height": 600, "legend": { "tracegroupgap": 0 }, "template": { "data": { "bar": [ { "error_x": { "color": "#2a3f5f" }, "error_y": { "color": "#2a3f5f" }, "marker": { "line": { "color": "#E5ECF6", "width": 0.5 }, "pattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 } }, "type": "bar" } ], "barpolar": [ { "marker": { "line": { "color": "#E5ECF6", "width": 0.5 }, "pattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 } }, "type": "barpolar" } ], "carpet": [ { "aaxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "baxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "type": "carpet" } ], "choropleth": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "choropleth" } ], "contour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "contour" } ], "contourcarpet": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "contourcarpet" } ], "heatmap": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmap" } ], "heatmapgl": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmapgl" } ], "histogram": [ { "marker": { "pattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 } }, "type": "histogram" } ], "histogram2d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2d" } ], "histogram2dcontour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2dcontour" } ], "mesh3d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "mesh3d" } ], "parcoords": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "parcoords" } ], "pie": [ { "automargin": true, "type": "pie" } ], "scatter": [ { "fillpattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 }, "type": "scatter" } ], "scatter3d": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter3d" } ], "scattercarpet": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattercarpet" } ], "scattergeo": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergeo" } ], "scattergl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergl" } ], "scattermapbox": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattermapbox" } ], "scatterpolar": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolar" } ], "scatterpolargl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolargl" } ], "scatterternary": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterternary" } ], "surface": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "surface" } ], "table": [ { "cells": { "fill": { "color": "#EBF0F8" }, "line": { "color": "white" } }, "header": { "fill": { "color": "#C8D4E3" }, "line": { "color": "white" } }, "type": "table" } ] }, "layout": { "annotationdefaults": { "arrowcolor": "#2a3f5f", "arrowhead": 0, "arrowwidth": 1 }, "autotypenumbers": "strict", "coloraxis": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "colorscale": { "diverging": [ [ 0, "#8e0152" ], [ 0.1, "#c51b7d" ], [ 0.2, "#de77ae" ], [ 0.3, "#f1b6da" ], [ 0.4, "#fde0ef" ], [ 0.5, "#f7f7f7" ], [ 0.6, "#e6f5d0" ], [ 0.7, "#b8e186" ], [ 0.8, "#7fbc41" ], [ 0.9, "#4d9221" ], [ 1, "#276419" ] ], "sequential": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "sequentialminus": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ] }, "colorway": [ "#636efa", "#EF553B", "#00cc96", "#ab63fa", "#FFA15A", "#19d3f3", "#FF6692", "#B6E880", "#FF97FF", "#FECB52" ], "font": { "color": "#2a3f5f" }, "geo": { "bgcolor": "white", "lakecolor": "white", "landcolor": "#E5ECF6", "showlakes": true, "showland": true, "subunitcolor": "white" }, "hoverlabel": { "align": "left" }, "hovermode": "closest", "mapbox": { "style": "light" }, "paper_bgcolor": "white", "plot_bgcolor": "#E5ECF6", "polar": { "angularaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "radialaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "scene": { "xaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "yaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "zaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" } }, "shapedefaults": { "line": { "color": "#2a3f5f" } }, "ternary": { "aaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "baxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "caxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "title": { "x": 0.05 }, "xaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 }, "yaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 } } }, "title": { "text": "Life Expectancy accross Regions in 2007" }, "width": 900 } } }, "metadata": {}, "output_type": "display_data" } ], "source": [ "fig = px.sunburst(df2, \n", " path=['continent', 'country'], \n", " values='pop',\n", " color='lifeExp', \n", " color_continuous_scale='RdBu',\n", " height=600, width=900,\n", " title='Life Expectancy accross Regions in 2007'\n", " )\n", "fig.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "3. Set the midpoint of the color bar to the average Life Expectancy weighted by the population size of each country" ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "avg_life_exp_pop = np.average(df2['lifeExp'], weights=df2['pop'])" ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [ { "data": { "application/vnd.plotly.v1+json": { "config": { "plotlyServerURL": "https://plot.ly" }, "data": [ { "branchvalues": "total", "customdata": [ [ "AFG", 43.828 ], [ "ALB", 76.423 ], [ "DZA", 72.301 ], [ "AGO", 42.731 ], [ "ARG", 75.32 ], [ "AUS", 81.235 ], [ "AUT", 79.829 ], [ "BHR", 75.635 ], [ "BGD", 64.062 ], [ "BEL", 79.441 ], [ "BEN", 56.728 ], [ "BOL", 65.554 ], [ "BIH", 74.852 ], [ "BWA", 50.728 ], [ "BRA", 72.39 ], [ "BGR", 73.005 ], [ "BFA", 52.295 ], [ "BDI", 49.58 ], [ "KHM", 59.723 ], [ "CMR", 50.43 ], [ "CAN", 80.65300000000002 ], [ "CAF", 44.74100000000001 ], [ "TCD", 50.651 ], [ "CHL", 78.553 ], [ "CHN", 72.961 ], [ "COL", 72.889 ], [ "COM", 65.152 ], [ "COD", 46.462 ], [ "COG", 55.322 ], [ "CRI", 78.782 ], [ "CIV", 48.328 ], [ "HRV", 75.748 ], [ "CUB", 78.273 ], [ "CZE", 76.486 ], [ "DNK", 78.332 ], [ "DJI", 54.791 ], [ "DOM", 72.235 ], [ "ECU", 74.994 ], [ "EGY", 71.33800000000002 ], [ "SLV", 71.878 ], [ "GNQ", 51.57899999999999 ], [ "ERI", 58.03999999999999 ], [ "ETH", 52.947 ], [ "FIN", 79.313 ], [ "FRA", 80.65699999999998 ], [ "GAB", 56.73500000000001 ], [ "GMB", 59.448 ], [ "DEU", 79.406 ], [ "GHA", 60.02199999999999 ], [ "GRC", 79.483 ], [ "GTM", 70.259 ], [ "GIN", 56.007 ], [ "GNB", 46.38800000000001 ], [ "HTI", 60.916 ], [ "HND", 70.19800000000001 ], [ "HKG", 82.208 ], [ "HUN", 73.33800000000002 ], [ "ISL", 81.757 ], [ "IND", 64.69800000000001 ], [ "IDN", 70.65 ], [ "IRN", 70.964 ], [ "IRQ", 59.545 ], [ "IRL", 78.885 ], [ "ISR", 80.745 ], [ "ITA", 80.546 ], [ "JAM", 72.567 ], [ "JPN", 82.603 ], [ "JOR", 72.535 ], [ "KEN", 54.11 ], [ "KOR", 67.297 ], [ "KOR", 78.623 ], [ "KWT", 77.58800000000002 ], [ "LBN", 71.993 ], [ "LSO", 42.592 ], [ "LBR", 45.678 ], [ "LBY", 73.952 ], [ "MDG", 59.443000000000005 ], [ "MWI", 48.303 ], [ "MYS", 74.241 ], [ "MLI", 54.467 ], [ "MRT", 64.164 ], [ "MUS", 72.801 ], [ "MEX", 76.195 ], [ "MNG", 66.803 ], [ "MNE", 74.543 ], [ "MAR", 71.164 ], [ "MOZ", 42.082 ], [ "MMR", 62.06900000000001 ], [ "NAM", 52.90600000000001 ], [ "NPL", 63.785 ], [ "NLD", 79.762 ], [ "NZL", 80.204 ], [ "NIC", 72.899 ], [ "NER", 56.867 ], [ "NGA", 46.859 ], [ "NOR", 80.196 ], [ "OMN", 75.64 ], [ "PAK", 65.483 ], [ "PAN", 75.53699999999998 ], [ "PRY", 71.752 ], [ "PER", 71.421 ], [ "PHL", 71.688 ], [ "POL", 75.563 ], [ "PRT", 78.098 ], [ "PRI", 78.74600000000002 ], [ "REU", 76.442 ], [ "ROU", 72.476 ], [ "RWA", 46.242 ], [ "STP", 65.528 ], [ "SAU", 72.777 ], [ "SEN", 63.062 ], [ "SRB", 74.002 ], [ "SLE", 42.56800000000001 ], [ "SGP", 79.972 ], [ "SVK", 74.663 ], [ "SVN", 77.926 ], [ "SOM", 48.159 ], [ "ZAF", 49.339 ], [ "ESP", 80.941 ], [ "LKA", 72.396 ], [ "SDN", 58.55599999999999 ], [ "SWZ", 39.613 ], [ "SWE", 80.884 ], [ "CHE", 81.70100000000002 ], [ "SYR", 74.143 ], [ "TWN", 78.4 ], [ "TZA", 52.517 ], [ "THA", 70.616 ], [ "TGO", 58.42 ], [ "TTO", 69.819 ], [ "TUN", 73.923 ], [ "TUR", 71.777 ], [ "UGA", 51.542 ], [ "GBR", 79.425 ], [ "USA", 78.242 ], [ "URY", 76.384 ], [ "VEN", 73.747 ], [ "VNM", 74.249 ], [ "PSE", 73.422 ], [ "YEM", 62.698 ], [ "ZMB", 42.38399999999999 ], [ "ZWE", 43.487 ], [ "(?)", 54.56441057558197 ], [ "(?)", 75.35668222743027 ], [ "(?)", 69.44386304205017 ], [ "(?)", 77.89057081069897 ], [ "(?)", 81.06215400970112 ] ], "domain": { "x": [ 0, 1 ], "y": [ 0, 1 ] }, "hovertemplate": "%{hovertext}

labels=%{label}
pop=%{value}
parent=%{parent}
id=%{id}
iso_alpha=%{customdata[0]}
lifeExp=%{color}", "hovertext": [ "Afghanistan", "Albania", "Algeria", "Angola", "Argentina", "Australia", "Austria", "Bahrain", "Bangladesh", "Belgium", "Benin", "Bolivia", "Bosnia and Herzegovina", "Botswana", "Brazil", "Bulgaria", "Burkina Faso", "Burundi", "Cambodia", "Cameroon", "Canada", "Central African Republic", "Chad", "Chile", "China", "Colombia", "Comoros", "Congo, Dem. Rep.", "Congo, Rep.", "Costa Rica", "Cote d'Ivoire", "Croatia", "Cuba", "Czech Republic", "Denmark", "Djibouti", "Dominican Republic", "Ecuador", "Egypt", "El Salvador", "Equatorial Guinea", "Eritrea", "Ethiopia", "Finland", "France", "Gabon", "Gambia", "Germany", "Ghana", "Greece", "Guatemala", "Guinea", "Guinea-Bissau", "Haiti", "Honduras", "Hong Kong, China", "Hungary", "Iceland", "India", "Indonesia", "Iran", "Iraq", "Ireland", "Israel", "Italy", "Jamaica", "Japan", "Jordan", "Kenya", "Korea, Dem. Rep.", "Korea, Rep.", "Kuwait", "Lebanon", "Lesotho", "Liberia", "Libya", "Madagascar", "Malawi", "Malaysia", "Mali", "Mauritania", "Mauritius", "Mexico", "Mongolia", "Montenegro", "Morocco", "Mozambique", "Myanmar", "Namibia", "Nepal", "Netherlands", "New Zealand", "Nicaragua", "Niger", "Nigeria", "Norway", "Oman", "Pakistan", "Panama", "Paraguay", "Peru", "Philippines", "Poland", "Portugal", "Puerto Rico", "Reunion", "Romania", "Rwanda", "Sao Tome and Principe", "Saudi Arabia", "Senegal", "Serbia", "Sierra Leone", "Singapore", "Slovak Republic", "Slovenia", "Somalia", "South Africa", "Spain", "Sri Lanka", "Sudan", "Swaziland", "Sweden", "Switzerland", "Syria", "Taiwan", "Tanzania", "Thailand", "Togo", "Trinidad and Tobago", "Tunisia", "Turkey", "Uganda", "United Kingdom", "United States", "Uruguay", "Venezuela", "Vietnam", "West Bank and Gaza", "Yemen, Rep.", "Zambia", "Zimbabwe", "(?)", "(?)", "(?)", "(?)", "(?)" ], "ids": [ "Asia/Afghanistan", "Europe/Albania", "Africa/Algeria", "Africa/Angola", "Americas/Argentina", "Oceania/Australia", "Europe/Austria", "Asia/Bahrain", "Asia/Bangladesh", "Europe/Belgium", "Africa/Benin", "Americas/Bolivia", "Europe/Bosnia and Herzegovina", "Africa/Botswana", "Americas/Brazil", "Europe/Bulgaria", "Africa/Burkina Faso", "Africa/Burundi", "Asia/Cambodia", "Africa/Cameroon", "Americas/Canada", "Africa/Central African Republic", "Africa/Chad", "Americas/Chile", "Asia/China", "Americas/Colombia", "Africa/Comoros", "Africa/Congo, Dem. Rep.", "Africa/Congo, Rep.", "Americas/Costa Rica", "Africa/Cote d'Ivoire", "Europe/Croatia", "Americas/Cuba", "Europe/Czech Republic", "Europe/Denmark", "Africa/Djibouti", "Americas/Dominican Republic", "Americas/Ecuador", "Africa/Egypt", "Americas/El Salvador", "Africa/Equatorial Guinea", "Africa/Eritrea", "Africa/Ethiopia", "Europe/Finland", "Europe/France", "Africa/Gabon", "Africa/Gambia", "Europe/Germany", "Africa/Ghana", "Europe/Greece", "Americas/Guatemala", "Africa/Guinea", "Africa/Guinea-Bissau", "Americas/Haiti", "Americas/Honduras", "Asia/Hong Kong, China", "Europe/Hungary", "Europe/Iceland", "Asia/India", "Asia/Indonesia", "Asia/Iran", "Asia/Iraq", "Europe/Ireland", "Asia/Israel", "Europe/Italy", "Americas/Jamaica", "Asia/Japan", "Asia/Jordan", "Africa/Kenya", "Asia/Korea, Dem. Rep.", "Asia/Korea, Rep.", "Asia/Kuwait", "Asia/Lebanon", "Africa/Lesotho", "Africa/Liberia", "Africa/Libya", "Africa/Madagascar", "Africa/Malawi", "Asia/Malaysia", "Africa/Mali", "Africa/Mauritania", "Africa/Mauritius", "Americas/Mexico", "Asia/Mongolia", "Europe/Montenegro", "Africa/Morocco", "Africa/Mozambique", "Asia/Myanmar", "Africa/Namibia", "Asia/Nepal", "Europe/Netherlands", "Oceania/New Zealand", "Americas/Nicaragua", "Africa/Niger", "Africa/Nigeria", "Europe/Norway", "Asia/Oman", "Asia/Pakistan", "Americas/Panama", "Americas/Paraguay", "Americas/Peru", "Asia/Philippines", "Europe/Poland", "Europe/Portugal", "Americas/Puerto Rico", "Africa/Reunion", "Europe/Romania", "Africa/Rwanda", "Africa/Sao Tome and Principe", "Asia/Saudi Arabia", "Africa/Senegal", "Europe/Serbia", "Africa/Sierra Leone", "Asia/Singapore", "Europe/Slovak Republic", "Europe/Slovenia", "Africa/Somalia", "Africa/South Africa", "Europe/Spain", "Asia/Sri Lanka", "Africa/Sudan", "Africa/Swaziland", "Europe/Sweden", "Europe/Switzerland", "Asia/Syria", "Asia/Taiwan", "Africa/Tanzania", "Asia/Thailand", "Africa/Togo", "Americas/Trinidad and Tobago", "Africa/Tunisia", "Europe/Turkey", "Africa/Uganda", "Europe/United Kingdom", "Americas/United States", "Americas/Uruguay", "Americas/Venezuela", "Asia/Vietnam", "Asia/West Bank and Gaza", "Asia/Yemen, Rep.", "Africa/Zambia", "Africa/Zimbabwe", "Africa", "Americas", "Asia", "Europe", "Oceania" ], "labels": [ "Afghanistan", "Albania", "Algeria", "Angola", "Argentina", "Australia", "Austria", "Bahrain", "Bangladesh", "Belgium", "Benin", "Bolivia", "Bosnia and Herzegovina", "Botswana", "Brazil", "Bulgaria", "Burkina Faso", "Burundi", "Cambodia", "Cameroon", "Canada", "Central African Republic", "Chad", "Chile", "China", "Colombia", "Comoros", "Congo, Dem. Rep.", "Congo, Rep.", "Costa Rica", "Cote d'Ivoire", "Croatia", "Cuba", "Czech Republic", "Denmark", "Djibouti", "Dominican Republic", "Ecuador", "Egypt", "El Salvador", "Equatorial Guinea", "Eritrea", "Ethiopia", "Finland", "France", "Gabon", "Gambia", "Germany", "Ghana", "Greece", "Guatemala", "Guinea", "Guinea-Bissau", "Haiti", "Honduras", "Hong Kong, China", "Hungary", "Iceland", "India", "Indonesia", "Iran", "Iraq", "Ireland", "Israel", "Italy", "Jamaica", "Japan", "Jordan", "Kenya", "Korea, Dem. Rep.", "Korea, Rep.", "Kuwait", "Lebanon", "Lesotho", "Liberia", "Libya", "Madagascar", "Malawi", "Malaysia", "Mali", "Mauritania", "Mauritius", "Mexico", "Mongolia", "Montenegro", "Morocco", "Mozambique", "Myanmar", "Namibia", "Nepal", "Netherlands", "New Zealand", "Nicaragua", "Niger", "Nigeria", "Norway", "Oman", "Pakistan", "Panama", "Paraguay", "Peru", "Philippines", "Poland", "Portugal", "Puerto Rico", "Reunion", "Romania", "Rwanda", "Sao Tome and Principe", "Saudi Arabia", "Senegal", "Serbia", "Sierra Leone", "Singapore", "Slovak Republic", "Slovenia", "Somalia", "South Africa", "Spain", "Sri Lanka", "Sudan", "Swaziland", "Sweden", "Switzerland", "Syria", "Taiwan", "Tanzania", "Thailand", "Togo", "Trinidad and Tobago", "Tunisia", "Turkey", "Uganda", "United Kingdom", "United States", "Uruguay", "Venezuela", "Vietnam", "West Bank and Gaza", "Yemen, Rep.", "Zambia", "Zimbabwe", "Africa", "Americas", "Asia", "Europe", "Oceania" ], "marker": { "coloraxis": "coloraxis", "colors": [ 43.828, 76.423, 72.301, 42.731, 75.32, 81.235, 79.829, 75.635, 64.062, 79.441, 56.728, 65.554, 74.852, 50.728, 72.39, 73.005, 52.295, 49.58, 59.723, 50.43, 80.65300000000002, 44.74100000000001, 50.651, 78.553, 72.961, 72.889, 65.152, 46.462, 55.322, 78.782, 48.328, 75.748, 78.273, 76.486, 78.332, 54.791, 72.235, 74.994, 71.33800000000002, 71.878, 51.57899999999999, 58.03999999999999, 52.947, 79.313, 80.65699999999998, 56.73500000000001, 59.448, 79.406, 60.02199999999999, 79.483, 70.259, 56.007, 46.38800000000001, 60.916, 70.19800000000001, 82.208, 73.33800000000002, 81.757, 64.69800000000001, 70.65, 70.964, 59.545, 78.885, 80.745, 80.546, 72.567, 82.603, 72.535, 54.11, 67.297, 78.623, 77.58800000000002, 71.993, 42.592, 45.678, 73.952, 59.443000000000005, 48.303, 74.241, 54.467, 64.164, 72.801, 76.195, 66.803, 74.543, 71.164, 42.082, 62.06900000000001, 52.90600000000001, 63.785, 79.762, 80.204, 72.899, 56.867, 46.859, 80.196, 75.64, 65.483, 75.53699999999998, 71.752, 71.421, 71.688, 75.563, 78.098, 78.74600000000002, 76.442, 72.476, 46.242, 65.528, 72.777, 63.062, 74.002, 42.56800000000001, 79.972, 74.663, 77.926, 48.159, 49.339, 80.941, 72.396, 58.55599999999999, 39.613, 80.884, 81.70100000000002, 74.143, 78.4, 52.517, 70.616, 58.42, 69.819, 73.923, 71.777, 51.542, 79.425, 78.242, 76.384, 73.747, 74.249, 73.422, 62.698, 42.38399999999999, 43.487, 54.56441057558197, 75.35668222743027, 69.44386304205017, 77.89057081069897, 81.06215400970112 ] }, "name": "", "parents": [ "Asia", "Europe", "Africa", "Africa", "Americas", "Oceania", "Europe", "Asia", "Asia", "Europe", "Africa", "Americas", "Europe", "Africa", "Americas", "Europe", "Africa", "Africa", "Asia", "Africa", "Americas", "Africa", "Africa", "Americas", "Asia", "Americas", "Africa", "Africa", "Africa", "Americas", "Africa", "Europe", "Americas", "Europe", "Europe", "Africa", "Americas", "Americas", "Africa", "Americas", "Africa", "Africa", "Africa", "Europe", "Europe", "Africa", "Africa", "Europe", "Africa", "Europe", "Americas", "Africa", "Africa", "Americas", "Americas", "Asia", "Europe", "Europe", "Asia", "Asia", "Asia", "Asia", "Europe", "Asia", "Europe", "Americas", "Asia", "Asia", "Africa", "Asia", "Asia", "Asia", "Asia", "Africa", "Africa", "Africa", "Africa", "Africa", "Asia", "Africa", "Africa", "Africa", "Americas", "Asia", "Europe", "Africa", "Africa", "Asia", "Africa", "Asia", "Europe", "Oceania", "Americas", "Africa", "Africa", "Europe", "Asia", "Asia", "Americas", "Americas", "Americas", "Asia", "Europe", "Europe", "Americas", "Africa", "Europe", "Africa", "Africa", "Asia", "Africa", "Europe", "Africa", "Asia", "Europe", "Europe", "Africa", "Africa", "Europe", "Asia", "Africa", "Africa", "Europe", "Europe", "Asia", "Asia", "Africa", "Asia", "Africa", "Americas", "Africa", "Europe", "Africa", "Europe", "Americas", "Americas", "Americas", "Asia", "Asia", "Asia", "Africa", "Africa", "", "", "", "", "" ], "type": "sunburst", "values": [ 31889923, 3600523, 33333216, 12420476, 40301927, 20434176, 8199783, 708573, 150448339, 10392226, 8078314, 9119152, 4552198, 1639131, 190010647, 7322858, 14326203, 8390505, 14131858, 17696293, 33390141, 4369038, 10238807, 16284741, 1318683096, 44227550, 710960, 64606759, 3800610, 4133884, 18013409, 4493312, 11416987, 10228744, 5468120, 496374, 9319622, 13755680, 80264543, 6939688, 551201, 4906585, 76511887, 5238460, 61083916, 1454867, 1688359, 82400996, 22873338, 10706290, 12572928, 9947814, 1472041, 8502814, 7483763, 6980412, 9956108, 301931, 1110396331, 223547000, 69453570, 27499638, 4109086, 6426679, 58147733, 2780132, 127467972, 6053193, 35610177, 23301725, 49044790, 2505559, 3921278, 2012649, 3193942, 6036914, 19167654, 13327079, 24821286, 12031795, 3270065, 1250882, 108700891, 2874127, 684736, 33757175, 19951656, 47761980, 2055080, 28901790, 16570613, 4115771, 5675356, 12894865, 135031164, 4627926, 3204897, 169270617, 3242173, 6667147, 28674757, 91077287, 38518241, 10642836, 3942491, 798094, 22276056, 8860588, 199579, 27601038, 12267493, 10150265, 6144562, 4553009, 5447502, 2009245, 9118773, 43997828, 40448191, 20378239, 42292929, 1133066, 9031088, 7554661, 19314747, 23174294, 38139640, 65068149, 5701579, 1056608, 10276158, 71158647, 29170398, 60776238, 301139947, 3447496, 26084662, 85262356, 4018332, 22211743, 11746035, 12311143, 929539692, 898871184, 3811953827, 586098529, 24549947 ] } ], "layout": { "coloraxis": { "cmid": 68.91909251904043, "colorbar": { "title": { "text": "lifeExp" } }, "colorscale": [ [ 0, "rgb(103,0,31)" ], [ 0.1, "rgb(178,24,43)" ], [ 0.2, "rgb(214,96,77)" ], [ 0.3, "rgb(244,165,130)" ], [ 0.4, "rgb(253,219,199)" ], [ 0.5, "rgb(247,247,247)" ], [ 0.6, "rgb(209,229,240)" ], [ 0.7, "rgb(146,197,222)" ], [ 0.8, "rgb(67,147,195)" ], [ 0.9, "rgb(33,102,172)" ], [ 1, "rgb(5,48,97)" ] ] }, "height": 600, "legend": { "tracegroupgap": 0 }, "template": { "data": { "bar": [ { "error_x": { "color": "#2a3f5f" }, "error_y": { "color": "#2a3f5f" }, "marker": { "line": { "color": "#E5ECF6", "width": 0.5 }, "pattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 } }, "type": "bar" } ], "barpolar": [ { "marker": { "line": { "color": "#E5ECF6", "width": 0.5 }, "pattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 } }, "type": "barpolar" } ], "carpet": [ { "aaxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "baxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "type": "carpet" } ], "choropleth": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "choropleth" } ], "contour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "contour" } ], "contourcarpet": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "contourcarpet" } ], "heatmap": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmap" } ], "heatmapgl": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmapgl" } ], "histogram": [ { "marker": { "pattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 } }, "type": "histogram" } ], "histogram2d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2d" } ], "histogram2dcontour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2dcontour" } ], "mesh3d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "mesh3d" } ], "parcoords": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "parcoords" } ], "pie": [ { "automargin": true, "type": "pie" } ], "scatter": [ { "fillpattern": { "fillmode": "overlay", "size": 10, "solidity": 0.2 }, "type": "scatter" } ], "scatter3d": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter3d" } ], "scattercarpet": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattercarpet" } ], "scattergeo": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergeo" } ], "scattergl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergl" } ], "scattermapbox": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattermapbox" } ], "scatterpolar": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolar" } ], "scatterpolargl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolargl" } ], "scatterternary": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterternary" } ], "surface": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "surface" } ], "table": [ { "cells": { "fill": { "color": "#EBF0F8" }, "line": { "color": "white" } }, "header": { "fill": { "color": "#C8D4E3" }, "line": { "color": "white" } }, "type": "table" } ] }, "layout": { "annotationdefaults": { "arrowcolor": "#2a3f5f", "arrowhead": 0, "arrowwidth": 1 }, "autotypenumbers": "strict", "coloraxis": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "colorscale": { "diverging": [ [ 0, "#8e0152" ], [ 0.1, "#c51b7d" ], [ 0.2, "#de77ae" ], [ 0.3, "#f1b6da" ], [ 0.4, "#fde0ef" ], [ 0.5, "#f7f7f7" ], [ 0.6, "#e6f5d0" ], [ 0.7, "#b8e186" ], [ 0.8, "#7fbc41" ], [ 0.9, "#4d9221" ], [ 1, "#276419" ] ], "sequential": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "sequentialminus": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ] }, "colorway": [ "#636efa", "#EF553B", "#00cc96", "#ab63fa", "#FFA15A", "#19d3f3", "#FF6692", "#B6E880", "#FF97FF", "#FECB52" ], "font": { "color": "#2a3f5f" }, "geo": { "bgcolor": "white", "lakecolor": "white", "landcolor": "#E5ECF6", "showlakes": true, "showland": true, "subunitcolor": "white" }, "hoverlabel": { "align": "left" }, "hovermode": "closest", "mapbox": { "style": "light" }, "paper_bgcolor": "white", "plot_bgcolor": "#E5ECF6", "polar": { "angularaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "radialaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "scene": { "xaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "yaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "zaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" } }, "shapedefaults": { "line": { "color": "#2a3f5f" } }, "ternary": { "aaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "baxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "caxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "title": { "x": 0.05 }, "xaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 }, "yaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 } } }, "title": { "text": "Life Expectancy accross Regions in 2007" }, "width": 900 } } }, "metadata": {}, "output_type": "display_data" } ], "source": [ "fig = px.sunburst(df2, path=['continent', 'country'], values='pop',\n", " color='lifeExp', \n", " color_continuous_scale='RdBu',\n", " color_continuous_midpoint=avg_life_exp_pop,\n", " hover_name='country',\n", " hover_data=['iso_alpha'],\n", " height=600, width=900,\n", " title='Life Expectancy accross Regions in 2007'\n", " )\n", "fig.show()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": ".venv", "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.11.4" } }, "nbformat": 4, "nbformat_minor": 2 }