{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Making Dot Plots" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "A [Dot Plot](https://en.wikipedia.org/wiki/Dot_plot_(statistics)), also known as a Cleveland Dot Plot, is a simple yet effective data visualization tool that displays quantitative data for various categories. It is most commonly used for comparing numerical values across two categories when you want to prioritize readability and avoid the clutter of other chart types.\n", "\n", "They are typically used as an alternative to bar charts. Instead of bars, dot plots use points (dots) aligned to show data values. Each dot represents a data point, and its position along an axis corresponds to a numerical value.\n", "\n", "Dot plots are often associated with William S. Cleveland, a statistician who popularised this form of data visualization in the context of exploratory data analysis. Cleveland’s work emphasised the value of simple, clear, and interpretable visualizations.\n", "\n", "🚀 When to use them:\n", "\n", "Dot plots are particularly useful when dealing with medium size datasets and when exact values are important. They are effective for **comparing multiple groups or categories** side by side, making them a great alternative to bar charts, particularly when data labels are long. They also work well for **showing small differences between values**, which might be harder to detect in bar charts due to the added area of the bars. Cleveland dot plots are frequently used in fields such as economics, healthcare, and business analytics to present comparisons in a straightforward and space-efficient manner.\n", "\n", "⚠️ Be aware:\n", "\n", "However, dot plots also have limitations that may make them unsuitable in certain scenarios. They can become **cluttered and difficult to interpret** when dealing with **large datasets**, as overlapping dots may obscure differences between values. Additionally, dot plots might not be as intuitive as bar charts for **audiences unfamiliar with them**, since people are generally more accustomed to interpreting length rather than dot position. Furthermore, for datasets with extreme values or very small variations, dots may be placed too close together, making it challenging to distinguish between them.\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Getting ready" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "To create the data set for this recipe, we need to read a `csv` file and filter some of its data" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import pandas as pd" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "data = pd.read_csv('data/data_recipe05.csv')\n", "data = data[['Reference area', 'Time period', 'Sex', 'Value', 'Country ISO3']]\n", "data = data[data['Sex']!='Total']" ] }, { "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", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
Reference areaTime periodSexValueCountry ISO3
1Greece2023Female6.340200GRC
2Italy2023Female9.822100ITA
3Mexico2022Male13.398436MEX
4Norway2023Female20.661200NOR
5Sweden2023Male22.065200SWE
\n", "
" ], "text/plain": [ " Reference area Time period Sex Value Country ISO3\n", "1 Greece 2023 Female 6.340200 GRC\n", "2 Italy 2023 Female 9.822100 ITA\n", "3 Mexico 2022 Male 13.398436 MEX\n", "4 Norway 2023 Female 20.661200 NOR\n", "5 Sweden 2023 Male 22.065200 SWE" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data.head()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## How to do it" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Using `plotly Express`" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "1. Import the `plotly.express` module as `px`" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "import plotly.express as px" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "df = data" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "2. Start by making a simple scatter plot using the function `scatter`. We are going to differentiate the two categories (Female and Male) using the inputs `color` and `symbol` both set to the relevant column, in this case `Sex`.\n" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "application/vnd.plotly.v1+json": { "config": { "plotlyServerURL": "https://plot.ly" }, "data": [ { "hovertemplate": "Sex=Female
Country ISO3=%{x}
Value=%{y}", "legendgroup": "Female", "marker": { "color": "#636efa", "symbol": "circle" }, "mode": "markers", "name": "Female", "orientation": "v", "showlegend": true, "type": "scatter", "x": [ "GRC", "ITA", "NOR", "CZE", "GBR", "ROU", "OECD", "KOR", "AUT", "LUX", "IRL", "SWE", "LTU", "HRV", "FIN", "FRA", "PRT", "CHE", "EU27", "BEL", "BGR", "ESP", "HUN", "COL", "DEU", "ISL", "DNK", "SVN", "NLD", "EU28", "SVK", "POL", "EST", "CHL", "CAN", "TUR", "LVA", "BRA", "MEX" ], "xaxis": "x", "y": [ 6.3402, 9.8221, 20.6612, 9.7562, 12.4069, 1.6474, 9.935724682068964, 12.53037175, 5.4433, 6.8359, 12.8749, 4.9019, 11.5083, 3.4155, 9.9121, 12.8304, 19.6454, 14.334, 9.2549, 4.7314, 1.3558, 15.3839, 6.0922, 9.69739797, 4.8557, 7.3378, 12.7882, 9.3437, 11.4195, 9.8872, 6.156, 7.708, 12.0603, 15.21341732, 12.04, 3.3736, 6.5019, 5.235, 11.7919203 ], "yaxis": "y" }, { "hovertemplate": "Sex=Male
Country ISO3=%{x}
Value=%{y}", "legendgroup": "Male", "marker": { "color": "#EF553B", "symbol": "diamond" }, "mode": "markers", "name": "Male", "orientation": "v", "showlegend": true, "type": "scatter", "x": [ "MEX", "SWE", "EU27", "LVA", "BGR", "CHE", "TUR", "ITA", "ROU", "FRA", "LTU", "HRV", "FIN", "COL", "IRL", "HUN", "DEU", "LUX", "GBR", "AUT", "POL", "DNK", "EST", "ISL", "GRC", "SVN", "ESP", "EU28", "KOR", "OECD", "BRA", "SVK", "NOR", "BEL", "CAN", "PRT", "CHL", "CZE", "NLD" ], "xaxis": "x", "y": [ 13.39843612, 22.0652, 19.1101, 14.1613, 2.6228, 28.2142, 7.0849, 17.7687, 5.27, 25.1185, 14.7388, 27.047, 30.2333, 12.1739402, 12.6004, 17.9011, 13.7205, 19.0381, 31.4415, 23.528, 14.9733, 24.8467, 28.469100000000005, 23.5752, 6.1347, 19.5473, 23.2493, 20.9232, 11.40916904, 20.10365410551724, 5.43, 14.5269, 28.6765, 17.4764, 28.9, 31.9929, 19.13282657, 13.1687, 30.2065 ], "yaxis": "y" } ], "layout": { "legend": { "title": { "text": "Sex" }, "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": "Women as a share of all 16-24 year-olds who can program" }, "xaxis": { "anchor": "y", "domain": [ 0, 1 ], "title": { "text": "Country ISO3" } }, "yaxis": { "anchor": "x", "domain": [ 0, 1 ], "title": { "text": "Value" } } } } }, "metadata": {}, "output_type": "display_data" } ], "source": [ "fig = px.scatter(df, x=\"Country ISO3\", y=\"Value\", \n", " color=\"Sex\", symbol=\"Sex\",\n", " title=\"Women as a share of all 16-24 year-olds who can program\"\n", " )\n", "fig.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "2. Add a title to your chart by passing a string as the input `title`" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "application/vnd.plotly.v1+json": { "config": { "plotlyServerURL": "https://plot.ly" }, "data": [ { "hovertemplate": "Sex=Female
Country ISO3=%{x}
Value=%{y}", "legendgroup": "Female", "marker": { "color": "#636efa", "symbol": "circle" }, "mode": "markers", "name": "Female", "orientation": "v", "showlegend": true, "type": "scatter", "x": [ "GRC", "ITA", "NOR", "CZE", "GBR", "ROU", "OECD", "KOR", "AUT", "LUX", "IRL", "SWE", "LTU", "HRV", "FIN", "FRA", "PRT", "CHE", "EU27", "BEL", "BGR", "ESP", "HUN", "COL", "DEU", "ISL", "DNK", "SVN", "NLD", "EU28", "SVK", "POL", "EST", "CHL", "CAN", "TUR", "LVA", "BRA", "MEX" ], "xaxis": "x", "y": [ 6.3402, 9.8221, 20.6612, 9.7562, 12.4069, 1.6474, 9.935724682068964, 12.53037175, 5.4433, 6.8359, 12.8749, 4.9019, 11.5083, 3.4155, 9.9121, 12.8304, 19.6454, 14.334, 9.2549, 4.7314, 1.3558, 15.3839, 6.0922, 9.69739797, 4.8557, 7.3378, 12.7882, 9.3437, 11.4195, 9.8872, 6.156, 7.708, 12.0603, 15.21341732, 12.04, 3.3736, 6.5019, 5.235, 11.7919203 ], "yaxis": "y" }, { "hovertemplate": "Sex=Male
Country ISO3=%{x}
Value=%{y}", "legendgroup": "Male", "marker": { "color": "#EF553B", "symbol": "diamond" }, "mode": "markers", "name": "Male", "orientation": "v", "showlegend": true, "type": "scatter", "x": [ "MEX", "SWE", "EU27", "LVA", "BGR", "CHE", "TUR", "ITA", "ROU", "FRA", "LTU", "HRV", "FIN", "COL", "IRL", "HUN", "DEU", "LUX", "GBR", "AUT", "POL", "DNK", "EST", "ISL", "GRC", "SVN", "ESP", "EU28", "KOR", "OECD", "BRA", "SVK", "NOR", "BEL", "CAN", "PRT", "CHL", "CZE", "NLD" ], "xaxis": "x", "y": [ 13.39843612, 22.0652, 19.1101, 14.1613, 2.6228, 28.2142, 7.0849, 17.7687, 5.27, 25.1185, 14.7388, 27.047, 30.2333, 12.1739402, 12.6004, 17.9011, 13.7205, 19.0381, 31.4415, 23.528, 14.9733, 24.8467, 28.469100000000005, 23.5752, 6.1347, 19.5473, 23.2493, 20.9232, 11.40916904, 20.10365410551724, 5.43, 14.5269, 28.6765, 17.4764, 28.9, 31.9929, 19.13282657, 13.1687, 30.2065 ], "yaxis": "y" } ], "layout": { "legend": { "title": { "text": "Sex" }, "tracegroupgap": 0 }, "margin": { "t": 60 }, "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 } } }, "xaxis": { "anchor": "y", "domain": [ 0, 1 ], "title": { "text": "Country ISO3" } }, "yaxis": { "anchor": "x", "domain": [ 0, 1 ], "title": { "text": "Value" } } } } }, "metadata": {}, "output_type": "display_data" } ], "source": [ "fig = px.scatter(df, x=\"Country ISO3\", y=\"Value\", \n", " color=\"Sex\", symbol=\"Sex\",\n", " )\n", "fig.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "3. Customise the size of the figure by using the inputs `height` and `width`. Both have to be integers and correspond to the size of the figure in pixels." ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "application/vnd.plotly.v1+json": { "config": { "plotlyServerURL": "https://plot.ly" }, "data": [ { "hovertemplate": "Sex=Female
Country ISO3=%{x}
Value=%{y}", "legendgroup": "Female", "marker": { "color": "#636efa", "symbol": "circle" }, "mode": "markers", "name": "Female", "orientation": "v", "showlegend": true, "type": "scatter", "x": [ "GRC", "ITA", "NOR", "CZE", "GBR", "ROU", "OECD", "KOR", "AUT", "LUX", "IRL", "SWE", "LTU", "HRV", "FIN", "FRA", "PRT", "CHE", "EU27", "BEL", "BGR", "ESP", "HUN", "COL", "DEU", "ISL", "DNK", "SVN", "NLD", "EU28", "SVK", "POL", "EST", "CHL", "CAN", "TUR", "LVA", "BRA", "MEX" ], "xaxis": "x", "y": [ 6.3402, 9.8221, 20.6612, 9.7562, 12.4069, 1.6474, 9.935724682068964, 12.53037175, 5.4433, 6.8359, 12.8749, 4.9019, 11.5083, 3.4155, 9.9121, 12.8304, 19.6454, 14.334, 9.2549, 4.7314, 1.3558, 15.3839, 6.0922, 9.69739797, 4.8557, 7.3378, 12.7882, 9.3437, 11.4195, 9.8872, 6.156, 7.708, 12.0603, 15.21341732, 12.04, 3.3736, 6.5019, 5.235, 11.7919203 ], "yaxis": "y" }, { "hovertemplate": "Sex=Male
Country ISO3=%{x}
Value=%{y}", "legendgroup": "Male", "marker": { "color": "#EF553B", "symbol": "diamond" }, "mode": "markers", "name": "Male", "orientation": "v", "showlegend": true, "type": "scatter", "x": [ "MEX", "SWE", "EU27", "LVA", "BGR", "CHE", "TUR", "ITA", "ROU", "FRA", "LTU", "HRV", "FIN", "COL", "IRL", "HUN", "DEU", "LUX", "GBR", "AUT", "POL", "DNK", "EST", "ISL", "GRC", "SVN", "ESP", "EU28", "KOR", "OECD", "BRA", "SVK", "NOR", "BEL", "CAN", "PRT", "CHL", "CZE", "NLD" ], "xaxis": "x", "y": [ 13.39843612, 22.0652, 19.1101, 14.1613, 2.6228, 28.2142, 7.0849, 17.7687, 5.27, 25.1185, 14.7388, 27.047, 30.2333, 12.1739402, 12.6004, 17.9011, 13.7205, 19.0381, 31.4415, 23.528, 14.9733, 24.8467, 28.469100000000005, 23.5752, 6.1347, 19.5473, 23.2493, 20.9232, 11.40916904, 20.10365410551724, 5.43, 14.5269, 28.6765, 17.4764, 28.9, 31.9929, 19.13282657, 13.1687, 30.2065 ], "yaxis": "y" } ], "layout": { "height": 500, "legend": { "title": { "text": "Sex" }, "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": "Women as a share of all 16-24 year-olds who can program" }, "width": 900, "xaxis": { "anchor": "y", "domain": [ 0, 1 ], "title": { "text": "Country ISO3" } }, "yaxis": { "anchor": "x", "domain": [ 0, 1 ], "title": { "text": "Value" } } } } }, "metadata": {}, "output_type": "display_data" } ], "source": [ "fig = px.scatter(df, x=\"Country ISO3\", y=\"Value\", \n", " color=\"Sex\",\n", " symbol=\"Sex\",\n", " title=\"Women as a share of all 16-24 year-olds who can program\",\n", " width=900, height=500\n", " )\n", "fig.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "4. 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": [ { "hovertemplate": "Sex=Female
Country ISO3=%{x}
Value=%{y}", "legendgroup": "Female", "marker": { "color": "rgb(228,26,28)", "symbol": "circle" }, "mode": "markers", "name": "Female", "orientation": "v", "showlegend": true, "type": "scatter", "x": [ "GRC", "ITA", "NOR", "CZE", "GBR", "ROU", "OECD", "KOR", "AUT", "LUX", "IRL", "SWE", "LTU", "HRV", "FIN", "FRA", "PRT", "CHE", "EU27", "BEL", "BGR", "ESP", "HUN", "COL", "DEU", "ISL", "DNK", "SVN", "NLD", "EU28", "SVK", "POL", "EST", "CHL", "CAN", "TUR", "LVA", "BRA", "MEX" ], "xaxis": "x", "y": [ 6.3402, 9.8221, 20.6612, 9.7562, 12.4069, 1.6474, 9.935724682068964, 12.53037175, 5.4433, 6.8359, 12.8749, 4.9019, 11.5083, 3.4155, 9.9121, 12.8304, 19.6454, 14.334, 9.2549, 4.7314, 1.3558, 15.3839, 6.0922, 9.69739797, 4.8557, 7.3378, 12.7882, 9.3437, 11.4195, 9.8872, 6.156, 7.708, 12.0603, 15.21341732, 12.04, 3.3736, 6.5019, 5.235, 11.7919203 ], "yaxis": "y" }, { "hovertemplate": "Sex=Male
Country ISO3=%{x}
Value=%{y}", "legendgroup": "Male", "marker": { "color": "rgb(55,126,184)", "symbol": "diamond" }, "mode": "markers", "name": "Male", "orientation": "v", "showlegend": true, "type": "scatter", "x": [ "MEX", "SWE", "EU27", "LVA", "BGR", "CHE", "TUR", "ITA", "ROU", "FRA", "LTU", "HRV", "FIN", "COL", "IRL", "HUN", "DEU", "LUX", "GBR", "AUT", "POL", "DNK", "EST", "ISL", "GRC", "SVN", "ESP", "EU28", "KOR", "OECD", "BRA", "SVK", "NOR", "BEL", "CAN", "PRT", "CHL", "CZE", "NLD" ], "xaxis": "x", "y": [ 13.39843612, 22.0652, 19.1101, 14.1613, 2.6228, 28.2142, 7.0849, 17.7687, 5.27, 25.1185, 14.7388, 27.047, 30.2333, 12.1739402, 12.6004, 17.9011, 13.7205, 19.0381, 31.4415, 23.528, 14.9733, 24.8467, 28.469100000000005, 23.5752, 6.1347, 19.5473, 23.2493, 20.9232, 11.40916904, 20.10365410551724, 5.43, 14.5269, 28.6765, 17.4764, 28.9, 31.9929, 19.13282657, 13.1687, 30.2065 ], "yaxis": "y" } ], "layout": { "height": 500, "legend": { "title": { "text": "Sex" }, "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": "Women as a share of all 16-24 year-olds who can program" }, "width": 900, "xaxis": { "anchor": "y", "domain": [ 0, 1 ], "title": { "text": "Country ISO3" } }, "yaxis": { "anchor": "x", "domain": [ 0, 1 ], "title": { "text": "Value" } } } } }, "metadata": {}, "output_type": "display_data" } ], "source": [ "fig = px.scatter(df, x=\"Country ISO3\", y=\"Value\", \n", " color=\"Sex\",\n", " symbol=\"Sex\",\n", " color_discrete_sequence = px.colors.qualitative.Set1,\n", " title=\"Women as a share of all 16-24 year-olds who can program\",\n", " width=900, height=500\n", " )\n", "fig.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Alternatively, you can specify the colors by using `color_discrete_map`. This allows you to pass a dictionary to map each category into a particular color." ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "application/vnd.plotly.v1+json": { "config": { "plotlyServerURL": "https://plot.ly" }, "data": [ { "hovertemplate": "Sex=Female
Country ISO3=%{x}
Value=%{y}", "legendgroup": "Female", "marker": { "color": "purple", "symbol": "circle" }, "mode": "markers", "name": "Female", "orientation": "v", "showlegend": true, "type": "scatter", "x": [ "GRC", "ITA", "NOR", "CZE", "GBR", "ROU", "OECD", "KOR", "AUT", "LUX", "IRL", "SWE", "LTU", "HRV", "FIN", "FRA", "PRT", "CHE", "EU27", "BEL", "BGR", "ESP", "HUN", "COL", "DEU", "ISL", "DNK", "SVN", "NLD", "EU28", "SVK", "POL", "EST", "CHL", "CAN", "TUR", "LVA", "BRA", "MEX" ], "xaxis": "x", "y": [ 6.3402, 9.8221, 20.6612, 9.7562, 12.4069, 1.6474, 9.935724682068964, 12.53037175, 5.4433, 6.8359, 12.8749, 4.9019, 11.5083, 3.4155, 9.9121, 12.8304, 19.6454, 14.334, 9.2549, 4.7314, 1.3558, 15.3839, 6.0922, 9.69739797, 4.8557, 7.3378, 12.7882, 9.3437, 11.4195, 9.8872, 6.156, 7.708, 12.0603, 15.21341732, 12.04, 3.3736, 6.5019, 5.235, 11.7919203 ], "yaxis": "y" }, { "hovertemplate": "Sex=Male
Country ISO3=%{x}
Value=%{y}", "legendgroup": "Male", "marker": { "color": "Green", "symbol": "diamond" }, "mode": "markers", "name": "Male", "orientation": "v", "showlegend": true, "type": "scatter", "x": [ "MEX", "SWE", "EU27", "LVA", "BGR", "CHE", "TUR", "ITA", "ROU", "FRA", "LTU", "HRV", "FIN", "COL", "IRL", "HUN", "DEU", "LUX", "GBR", "AUT", "POL", "DNK", "EST", "ISL", "GRC", "SVN", "ESP", "EU28", "KOR", "OECD", "BRA", "SVK", "NOR", "BEL", "CAN", "PRT", "CHL", "CZE", "NLD" ], "xaxis": "x", "y": [ 13.39843612, 22.0652, 19.1101, 14.1613, 2.6228, 28.2142, 7.0849, 17.7687, 5.27, 25.1185, 14.7388, 27.047, 30.2333, 12.1739402, 12.6004, 17.9011, 13.7205, 19.0381, 31.4415, 23.528, 14.9733, 24.8467, 28.469100000000005, 23.5752, 6.1347, 19.5473, 23.2493, 20.9232, 11.40916904, 20.10365410551724, 5.43, 14.5269, 28.6765, 17.4764, 28.9, 31.9929, 19.13282657, 13.1687, 30.2065 ], "yaxis": "y" } ], "layout": { "height": 500, "legend": { "title": { "text": "Sex" }, "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": "Women as a share of all 16-24 year-olds who can program" }, "width": 900, "xaxis": { "anchor": "y", "domain": [ 0, 1 ], "title": { "text": "Country ISO3" } }, "yaxis": { "anchor": "x", "domain": [ 0, 1 ], "title": { "text": "Value" } } } } }, "metadata": {}, "output_type": "display_data" } ], "source": [ "fig = px.scatter(df, x=\"Country ISO3\", y=\"Value\", \n", " color=\"Sex\",\n", " symbol=\"Sex\",\n", " color_discrete_map = {'Female':'purple', 'Male':'Green'},\n", " title=\"Women as a share of all 16-24 year-olds who can program\",\n", " width=900, height=500\n", " )\n", "fig.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Note: You don't have to specify all the categories available in the mapping. For example, in the following snippet we only set the color for the category 'Female' and left the rest to `plotly`" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "application/vnd.plotly.v1+json": { "config": { "plotlyServerURL": "https://plot.ly" }, "data": [ { "hovertemplate": "Sex=Female
Country ISO3=%{x}
Value=%{y}", "legendgroup": "Female", "marker": { "color": "purple", "symbol": "circle" }, "mode": "markers", "name": "Female", "orientation": "v", "showlegend": true, "type": "scatter", "x": [ "GRC", "ITA", "NOR", "CZE", "GBR", "ROU", "OECD", "KOR", "AUT", "LUX", "IRL", "SWE", "LTU", "HRV", "FIN", "FRA", "PRT", "CHE", "EU27", "BEL", "BGR", "ESP", "HUN", "COL", "DEU", "ISL", "DNK", "SVN", "NLD", "EU28", "SVK", "POL", "EST", "CHL", "CAN", "TUR", "LVA", "BRA", "MEX" ], "xaxis": "x", "y": [ 6.3402, 9.8221, 20.6612, 9.7562, 12.4069, 1.6474, 9.935724682068964, 12.53037175, 5.4433, 6.8359, 12.8749, 4.9019, 11.5083, 3.4155, 9.9121, 12.8304, 19.6454, 14.334, 9.2549, 4.7314, 1.3558, 15.3839, 6.0922, 9.69739797, 4.8557, 7.3378, 12.7882, 9.3437, 11.4195, 9.8872, 6.156, 7.708, 12.0603, 15.21341732, 12.04, 3.3736, 6.5019, 5.235, 11.7919203 ], "yaxis": "y" }, { "hovertemplate": "Sex=Male
Country ISO3=%{x}
Value=%{y}", "legendgroup": "Male", "marker": { "color": "#EF553B", "symbol": "diamond" }, "mode": "markers", "name": "Male", "orientation": "v", "showlegend": true, "type": "scatter", "x": [ "MEX", "SWE", "EU27", "LVA", "BGR", "CHE", "TUR", "ITA", "ROU", "FRA", "LTU", "HRV", "FIN", "COL", "IRL", "HUN", "DEU", "LUX", "GBR", "AUT", "POL", "DNK", "EST", "ISL", "GRC", "SVN", "ESP", "EU28", "KOR", "OECD", "BRA", "SVK", "NOR", "BEL", "CAN", "PRT", "CHL", "CZE", "NLD" ], "xaxis": "x", "y": [ 13.39843612, 22.0652, 19.1101, 14.1613, 2.6228, 28.2142, 7.0849, 17.7687, 5.27, 25.1185, 14.7388, 27.047, 30.2333, 12.1739402, 12.6004, 17.9011, 13.7205, 19.0381, 31.4415, 23.528, 14.9733, 24.8467, 28.469100000000005, 23.5752, 6.1347, 19.5473, 23.2493, 20.9232, 11.40916904, 20.10365410551724, 5.43, 14.5269, 28.6765, 17.4764, 28.9, 31.9929, 19.13282657, 13.1687, 30.2065 ], "yaxis": "y" } ], "layout": { "height": 500, "legend": { "title": { "text": "Sex" }, "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": "Women as a share of all 16-24 year-olds who can program" }, "width": 900, "xaxis": { "anchor": "y", "domain": [ 0, 1 ], "title": { "text": "Country ISO3" } }, "yaxis": { "anchor": "x", "domain": [ 0, 1 ], "title": { "text": "Value" } } } } }, "metadata": {}, "output_type": "display_data" } ], "source": [ "fig = px.scatter(df, x=\"Country ISO3\", y=\"Value\", \n", " color=\"Sex\",\n", " symbol=\"Sex\",\n", " color_discrete_map = {'Female':'purple'},\n", " title=\"Women as a share of all 16-24 year-olds who can program\",\n", " width=900, height=500\n", " )\n", "fig.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "5. Change the orientation of the x-axis text by calling the Figure method `update_xaxis` and passing a dictionary with the `value` -90 into the key `tickangle`. This has the effect of rotating the text by -90 degrees." ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "data": { "application/vnd.plotly.v1+json": { "config": { "plotlyServerURL": "https://plot.ly" }, "data": [ { "hovertemplate": "Sex=Female
Country ISO3=%{x}
Value=%{y}", "legendgroup": "Female", "marker": { "color": "purple", "symbol": "circle" }, "mode": "markers", "name": "Female", "orientation": "v", "showlegend": true, "type": "scatter", "x": [ "GRC", "ITA", "NOR", "CZE", "GBR", "ROU", "OECD", "KOR", "AUT", "LUX", "IRL", "SWE", "LTU", "HRV", "FIN", "FRA", "PRT", "CHE", "EU27", "BEL", "BGR", "ESP", "HUN", "COL", "DEU", "ISL", "DNK", "SVN", "NLD", "EU28", "SVK", "POL", "EST", "CHL", "CAN", "TUR", "LVA", "BRA", "MEX" ], "xaxis": "x", "y": [ 6.3402, 9.8221, 20.6612, 9.7562, 12.4069, 1.6474, 9.935724682068964, 12.53037175, 5.4433, 6.8359, 12.8749, 4.9019, 11.5083, 3.4155, 9.9121, 12.8304, 19.6454, 14.334, 9.2549, 4.7314, 1.3558, 15.3839, 6.0922, 9.69739797, 4.8557, 7.3378, 12.7882, 9.3437, 11.4195, 9.8872, 6.156, 7.708, 12.0603, 15.21341732, 12.04, 3.3736, 6.5019, 5.235, 11.7919203 ], "yaxis": "y" }, { "hovertemplate": "Sex=Male
Country ISO3=%{x}
Value=%{y}", "legendgroup": "Male", "marker": { "color": "Green", "symbol": "diamond" }, "mode": "markers", "name": "Male", "orientation": "v", "showlegend": true, "type": "scatter", "x": [ "MEX", "SWE", "EU27", "LVA", "BGR", "CHE", "TUR", "ITA", "ROU", "FRA", "LTU", "HRV", "FIN", "COL", "IRL", "HUN", "DEU", "LUX", "GBR", "AUT", "POL", "DNK", "EST", "ISL", "GRC", "SVN", "ESP", "EU28", "KOR", "OECD", "BRA", "SVK", "NOR", "BEL", "CAN", "PRT", "CHL", "CZE", "NLD" ], "xaxis": "x", "y": [ 13.39843612, 22.0652, 19.1101, 14.1613, 2.6228, 28.2142, 7.0849, 17.7687, 5.27, 25.1185, 14.7388, 27.047, 30.2333, 12.1739402, 12.6004, 17.9011, 13.7205, 19.0381, 31.4415, 23.528, 14.9733, 24.8467, 28.469100000000005, 23.5752, 6.1347, 19.5473, 23.2493, 20.9232, 11.40916904, 20.10365410551724, 5.43, 14.5269, 28.6765, 17.4764, 28.9, 31.9929, 19.13282657, 13.1687, 30.2065 ], "yaxis": "y" } ], "layout": { "height": 500, "legend": { "title": { "text": "Sex" }, "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": "Women as a share of all 16-24 year-olds who can program" }, "width": 900, "xaxis": { "anchor": "y", "domain": [ 0, 1 ], "tickangle": -90, "title": { "text": "Country ISO3" } }, "yaxis": { "anchor": "x", "domain": [ 0, 1 ], "title": { "text": "Value" } } } } }, "metadata": {}, "output_type": "display_data" } ], "source": [ "fig = px.scatter(df, x=\"Country ISO3\", y=\"Value\", \n", " color=\"Sex\",\n", " symbol=\"Sex\",\n", " color_discrete_map = {'Female':'purple', 'Male':'Green'},\n", " title=\"Women as a share of all 16-24 year-olds who can program\",\n", " width=900, height=500\n", " )\n", "fig.update_xaxes({'tickangle':-90})\n", "fig.show()\n", "\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We can get the same effect by using the Figure method `update_layout` as follows:" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "data": { "application/vnd.plotly.v1+json": { "config": { "plotlyServerURL": "https://plot.ly" }, "data": [ { "hovertemplate": "Sex=Female
Country ISO3=%{x}
Value=%{y}", "legendgroup": "Female", "marker": { "color": "purple", "symbol": "circle" }, "mode": "markers", "name": "Female", "orientation": "v", "showlegend": true, "type": "scatter", "x": [ "GRC", "ITA", "NOR", "CZE", "GBR", "ROU", "OECD", "KOR", "AUT", "LUX", "IRL", "SWE", "LTU", "HRV", "FIN", "FRA", "PRT", "CHE", "EU27", "BEL", "BGR", "ESP", "HUN", "COL", "DEU", "ISL", "DNK", "SVN", "NLD", "EU28", "SVK", "POL", "EST", "CHL", "CAN", "TUR", "LVA", "BRA", "MEX" ], "xaxis": "x", "y": [ 6.3402, 9.8221, 20.6612, 9.7562, 12.4069, 1.6474, 9.935724682068964, 12.53037175, 5.4433, 6.8359, 12.8749, 4.9019, 11.5083, 3.4155, 9.9121, 12.8304, 19.6454, 14.334, 9.2549, 4.7314, 1.3558, 15.3839, 6.0922, 9.69739797, 4.8557, 7.3378, 12.7882, 9.3437, 11.4195, 9.8872, 6.156, 7.708, 12.0603, 15.21341732, 12.04, 3.3736, 6.5019, 5.235, 11.7919203 ], "yaxis": "y" }, { "hovertemplate": "Sex=Male
Country ISO3=%{x}
Value=%{y}", "legendgroup": "Male", "marker": { "color": "Green", "symbol": "diamond" }, "mode": "markers", "name": "Male", "orientation": "v", "showlegend": true, "type": "scatter", "x": [ "MEX", "SWE", "EU27", "LVA", "BGR", "CHE", "TUR", "ITA", "ROU", "FRA", "LTU", "HRV", "FIN", "COL", "IRL", "HUN", "DEU", "LUX", "GBR", "AUT", "POL", "DNK", "EST", "ISL", "GRC", "SVN", "ESP", "EU28", "KOR", "OECD", "BRA", "SVK", "NOR", "BEL", "CAN", "PRT", "CHL", "CZE", "NLD" ], "xaxis": "x", "y": [ 13.39843612, 22.0652, 19.1101, 14.1613, 2.6228, 28.2142, 7.0849, 17.7687, 5.27, 25.1185, 14.7388, 27.047, 30.2333, 12.1739402, 12.6004, 17.9011, 13.7205, 19.0381, 31.4415, 23.528, 14.9733, 24.8467, 28.469100000000005, 23.5752, 6.1347, 19.5473, 23.2493, 20.9232, 11.40916904, 20.10365410551724, 5.43, 14.5269, 28.6765, 17.4764, 28.9, 31.9929, 19.13282657, 13.1687, 30.2065 ], "yaxis": "y" } ], "layout": { "height": 500, "legend": { "title": { "text": "Sex" }, "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": "Women as a share of all 16-24 year-olds who can program" }, "width": 900, "xaxis": { "anchor": "y", "domain": [ 0, 1 ], "tickangle": -90, "title": { "text": "Country ISO3" } }, "yaxis": { "anchor": "x", "domain": [ 0, 1 ], "title": { "text": "Value" } } } } }, "metadata": {}, "output_type": "display_data" } ], "source": [ "fig = px.scatter(df, x=\"Country ISO3\", y=\"Value\", \n", " color=\"Sex\",\n", " symbol=\"Sex\",\n", " color_discrete_map = {'Female':'purple', 'Male':'Green'},\n", " title=\"Women as a share of all 16-24 year-olds who can program\",\n", " width=900, height=500\n", " )\n", "fig.update_layout(xaxis={'tickangle':-90})\n", "fig.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Using `plotly Go`" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "1. Import the Plotly Graph Objects library as `go`" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [], "source": [ "import plotly.graph_objects as go" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "1. Define a blank figue using the method `Figure`" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "data": { "application/vnd.plotly.v1+json": { "config": { "plotlyServerURL": "https://plot.ly" }, "data": [], "layout": { "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 } } } } } }, "metadata": {}, "output_type": "display_data" } ], "source": [ "fig = go.Figure()\n", "fig.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "2. Use the method `update_layout` to add a title and customise the figure size, using the inputs\n", "- `title`\n", "- `width` and `height`\n", "respectivelyl." ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [ { "data": { "application/vnd.plotly.v1+json": { "config": { "plotlyServerURL": "https://plot.ly" }, "data": [], "layout": { "height": 500, "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": "Female/Male as a share of all 16-24 year-olds who can program" }, "width": 900 } } }, "metadata": {}, "output_type": "display_data" } ], "source": [ "fig = go.Figure()\n", "\n", "fig.update_layout(title=\"Female/Male as a share of all 16-24 year-olds who can program\", \n", " width=900, height=500)\n", "\n", "fig.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "3. Loop over the unique values in the column which define the `x` values, in this case `Country ISO3`.\n", "For each value: Get the subset of the data matching each value. Then, extract the values corresponding to each category (in this case 'Female', 'Male'). Add a trace for each of these extracts, by calling `go.Scatter`.\n", "\n", "Notes:\n", "\n", "- We specify the markers by passina a dictionary as the `marker` input. This allows you great customisation of the symbols.\n", "- We call the method `update_layout` and pass `showlegend=False`. This prevents the legend to appear next to the chart. In this case, we will have too many labels (one per each trace) resulting on an overcrowded figure. So, we hide them." ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [ { "data": { "application/vnd.plotly.v1+json": { "config": { "plotlyServerURL": "https://plot.ly" }, "data": [ { "marker": { "color": "purple", "size": 7, "symbol": "circle" }, "type": "scatter", "x": [ "GRC" ], "y": [ 6.3402 ] }, { "marker": { "color": "green", "size": 7, "symbol": "diamond" }, "type": "scatter", "x": [ "GRC" ], "y": [ 6.1347 ] }, { "marker": { "color": "purple", "size": 7, "symbol": "circle" }, "type": "scatter", "x": [ "ITA" ], "y": [ 9.8221 ] }, { "marker": { "color": "green", "size": 7, "symbol": "diamond" }, "type": "scatter", "x": [ "ITA" ], "y": [ 17.7687 ] }, { "marker": { "color": "purple", "size": 7, "symbol": "circle" }, "type": "scatter", "x": [ "MEX" ], "y": [ 11.7919203 ] }, { "marker": { "color": "green", "size": 7, "symbol": "diamond" }, "type": "scatter", "x": [ "MEX" ], "y": [ 13.39843612 ] }, { "marker": { "color": "purple", "size": 7, "symbol": "circle" }, "type": "scatter", "x": [ "NOR" ], "y": [ 20.6612 ] }, { "marker": { "color": "green", "size": 7, "symbol": "diamond" }, "type": "scatter", "x": [ "NOR" ], "y": [ 28.6765 ] }, { "marker": { "color": "purple", "size": 7, "symbol": "circle" }, "type": "scatter", "x": [ "SWE" ], "y": [ 4.9019 ] }, { "marker": { "color": "green", "size": 7, "symbol": "diamond" }, "type": "scatter", "x": [ "SWE" ], "y": [ 22.0652 ] }, { "marker": { "color": "purple", "size": 7, "symbol": "circle" }, "type": "scatter", "x": [ "CZE" ], "y": [ 9.7562 ] }, { "marker": { "color": "green", "size": 7, "symbol": "diamond" }, "type": "scatter", "x": [ "CZE" ], "y": [ 13.1687 ] }, { "marker": { "color": "purple", "size": 7, "symbol": "circle" }, "type": "scatter", "x": [ "EU27" ], "y": [ 9.2549 ] }, { "marker": { "color": "green", "size": 7, "symbol": "diamond" }, "type": "scatter", "x": [ "EU27" ], "y": [ 19.1101 ] }, { "marker": { "color": "purple", "size": 7, "symbol": "circle" }, "type": "scatter", "x": [ "GBR" ], "y": [ 12.4069 ] }, { "marker": { "color": "green", "size": 7, "symbol": "diamond" }, "type": "scatter", "x": [ "GBR" ], "y": [ 31.4415 ] }, { "marker": { "color": "purple", "size": 7, "symbol": "circle" }, "type": "scatter", "x": [ "ROU" ], "y": [ 1.6474 ] }, { "marker": { "color": "green", "size": 7, "symbol": "diamond" }, "type": "scatter", "x": [ "ROU" ], "y": [ 5.27 ] }, { "marker": { "color": "purple", "size": 7, "symbol": "circle" }, "type": "scatter", "x": [ "LVA" ], "y": [ 6.5019 ] }, { "marker": { "color": "green", "size": 7, "symbol": "diamond" }, "type": "scatter", "x": [ "LVA" ], "y": [ 14.1613 ] }, { "marker": { "color": "purple", "size": 7, "symbol": "circle" }, "type": "scatter", "x": [ "OECD" ], "y": [ 9.935724682068964 ] }, { "marker": { "color": "green", "size": 7, "symbol": "diamond" }, "type": "scatter", "x": [ "OECD" ], "y": [ 20.10365410551724 ] }, { "marker": { "color": "purple", "size": 7, "symbol": "circle" }, "type": "scatter", "x": [ "BGR" ], "y": [ 1.3558 ] }, { "marker": { "color": "green", "size": 7, "symbol": "diamond" }, "type": "scatter", "x": [ "BGR" ], "y": [ 2.6228 ] }, { "marker": { "color": "purple", "size": 7, "symbol": "circle" }, "type": "scatter", "x": [ "CHE" ], "y": [ 14.334 ] }, { "marker": { "color": "green", "size": 7, "symbol": "diamond" }, "type": "scatter", "x": [ "CHE" ], "y": [ 28.2142 ] }, { "marker": { "color": "purple", "size": 7, "symbol": "circle" }, "type": "scatter", "x": [ "KOR" ], "y": [ 12.53037175 ] }, { "marker": { "color": "green", "size": 7, "symbol": "diamond" }, "type": "scatter", "x": [ "KOR" ], "y": [ 11.40916904 ] }, { "marker": { "color": "purple", "size": 7, "symbol": "circle" }, "type": "scatter", "x": [ "AUT" ], "y": [ 5.4433 ] }, { "marker": { "color": "green", "size": 7, "symbol": "diamond" }, "type": "scatter", "x": [ "AUT" ], "y": [ 23.528 ] }, { "marker": { "color": "purple", "size": 7, "symbol": "circle" }, "type": "scatter", "x": [ "TUR" ], "y": [ 3.3736 ] }, { "marker": { "color": "green", "size": 7, "symbol": "diamond" }, "type": "scatter", "x": [ "TUR" ], "y": [ 7.0849 ] }, { "marker": { "color": "purple", "size": 7, "symbol": "circle" }, "type": "scatter", "x": [ "LUX" ], "y": [ 6.8359 ] }, { "marker": { "color": "green", "size": 7, "symbol": "diamond" }, "type": "scatter", "x": [ "LUX" ], "y": [ 19.0381 ] }, { "marker": { "color": "purple", "size": 7, "symbol": "circle" }, "type": "scatter", "x": [ "IRL" ], "y": [ 12.8749 ] }, { "marker": { "color": "green", "size": 7, "symbol": "diamond" }, "type": "scatter", "x": [ "IRL" ], "y": [ 12.6004 ] }, { "marker": { "color": "purple", "size": 7, "symbol": "circle" }, "type": "scatter", "x": [ "LTU" ], "y": [ 11.5083 ] }, { "marker": { "color": "green", "size": 7, "symbol": "diamond" }, "type": "scatter", "x": [ "LTU" ], "y": [ 14.7388 ] }, { "marker": { "color": "purple", "size": 7, "symbol": "circle" }, "type": "scatter", "x": [ "FRA" ], "y": [ 12.8304 ] }, { "marker": { "color": "green", "size": 7, "symbol": "diamond" }, "type": "scatter", "x": [ "FRA" ], "y": [ 25.1185 ] }, { "marker": { "color": "purple", "size": 7, "symbol": "circle" }, "type": "scatter", "x": [ "HRV" ], "y": [ 3.4155 ] }, { "marker": { "color": "green", "size": 7, "symbol": "diamond" }, "type": "scatter", "x": [ "HRV" ], "y": [ 27.047 ] }, { "marker": { "color": "purple", "size": 7, "symbol": "circle" }, "type": "scatter", "x": [ "FIN" ], "y": [ 9.9121 ] }, { "marker": { "color": "green", "size": 7, "symbol": "diamond" }, "type": "scatter", "x": [ "FIN" ], "y": [ 30.2333 ] }, { "marker": { "color": "purple", "size": 7, "symbol": "circle" }, "type": "scatter", "x": [ "PRT" ], "y": [ 19.6454 ] }, { "marker": { "color": "green", "size": 7, "symbol": "diamond" }, "type": "scatter", "x": [ "PRT" ], "y": [ 31.9929 ] }, { "marker": { "color": "purple", "size": 7, "symbol": "circle" }, "type": "scatter", "x": [ "COL" ], "y": [ 9.69739797 ] }, { "marker": { "color": "green", "size": 7, "symbol": "diamond" }, "type": "scatter", "x": [ "COL" ], "y": [ 12.1739402 ] }, { "marker": { "color": "purple", "size": 7, "symbol": "circle" }, "type": "scatter", "x": [ "HUN" ], "y": [ 6.0922 ] }, { "marker": { "color": "green", "size": 7, "symbol": "diamond" }, "type": "scatter", "x": [ "HUN" ], "y": [ 17.9011 ] }, { "marker": { "color": "purple", "size": 7, "symbol": "circle" }, "type": "scatter", "x": [ "DEU" ], "y": [ 4.8557 ] }, { "marker": { "color": "green", "size": 7, "symbol": "diamond" }, "type": "scatter", "x": [ "DEU" ], "y": [ 13.7205 ] }, { "marker": { "color": "purple", "size": 7, "symbol": "circle" }, "type": "scatter", "x": [ "BEL" ], "y": [ 4.7314 ] }, { "marker": { "color": "green", "size": 7, "symbol": "diamond" }, "type": "scatter", "x": [ "BEL" ], "y": [ 17.4764 ] }, { "marker": { "color": "purple", "size": 7, "symbol": "circle" }, "type": "scatter", "x": [ "ESP" ], "y": [ 15.3839 ] }, { "marker": { "color": "green", "size": 7, "symbol": "diamond" }, "type": "scatter", "x": [ "ESP" ], "y": [ 23.2493 ] }, { "marker": { "color": "purple", "size": 7, "symbol": "circle" }, "type": "scatter", "x": [ "POL" ], "y": [ 7.708 ] }, { "marker": { "color": "green", "size": 7, "symbol": "diamond" }, "type": "scatter", "x": [ "POL" ], "y": [ 14.9733 ] }, { "marker": { "color": "purple", "size": 7, "symbol": "circle" }, "type": "scatter", "x": [ "DNK" ], "y": [ 12.7882 ] }, { "marker": { "color": "green", "size": 7, "symbol": "diamond" }, "type": "scatter", "x": [ "DNK" ], "y": [ 24.8467 ] }, { "marker": { "color": "purple", "size": 7, "symbol": "circle" }, "type": "scatter", "x": [ "EST" ], "y": [ 12.0603 ] }, { "marker": { "color": "green", "size": 7, "symbol": "diamond" }, "type": "scatter", "x": [ "EST" ], "y": [ 28.469100000000005 ] }, { "marker": { "color": "purple", "size": 7, "symbol": "circle" }, "type": "scatter", "x": [ "ISL" ], "y": [ 7.3378 ] }, { "marker": { "color": "green", "size": 7, "symbol": "diamond" }, "type": "scatter", "x": [ "ISL" ], "y": [ 23.5752 ] }, { "marker": { "color": "purple", "size": 7, "symbol": "circle" }, "type": "scatter", "x": [ "SVN" ], "y": [ 9.3437 ] }, { "marker": { "color": "green", "size": 7, "symbol": "diamond" }, "type": "scatter", "x": [ "SVN" ], "y": [ 19.5473 ] }, { "marker": { "color": "purple", "size": 7, "symbol": "circle" }, "type": "scatter", "x": [ "EU28" ], "y": [ 9.8872 ] }, { "marker": { "color": "green", "size": 7, "symbol": "diamond" }, "type": "scatter", "x": [ "EU28" ], "y": [ 20.9232 ] }, { "marker": { "color": "purple", "size": 7, "symbol": "circle" }, "type": "scatter", "x": [ "NLD" ], "y": [ 11.4195 ] }, { "marker": { "color": "green", "size": 7, "symbol": "diamond" }, "type": "scatter", "x": [ "NLD" ], "y": [ 30.2065 ] }, { "marker": { "color": "purple", "size": 7, "symbol": "circle" }, "type": "scatter", "x": [ "SVK" ], "y": [ 6.156 ] }, { "marker": { "color": "green", "size": 7, "symbol": "diamond" }, "type": "scatter", "x": [ "SVK" ], "y": [ 14.5269 ] }, { "marker": { "color": "purple", "size": 7, "symbol": "circle" }, "type": "scatter", "x": [ "BRA" ], "y": [ 5.235 ] }, { "marker": { "color": "green", "size": 7, "symbol": "diamond" }, "type": "scatter", "x": [ "BRA" ], "y": [ 5.43 ] }, { "marker": { "color": "purple", "size": 7, "symbol": "circle" }, "type": "scatter", "x": [ "CAN" ], "y": [ 12.04 ] }, { "marker": { "color": "green", "size": 7, "symbol": "diamond" }, "type": "scatter", "x": [ "CAN" ], "y": [ 28.9 ] }, { "marker": { "color": "purple", "size": 7, "symbol": "circle" }, "type": "scatter", "x": [ "CHL" ], "y": [ 15.21341732 ] }, { "marker": { "color": "green", "size": 7, "symbol": "diamond" }, "type": "scatter", "x": [ "CHL" ], "y": [ 19.13282657 ] } ], "layout": { "height": 500, "showlegend": false, "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": "Female/Male as a share of all 16-24 year-olds who can program" }, "width": 900 } } }, "metadata": {}, "output_type": "display_data" } ], "source": [ "fig = go.Figure()\n", "\n", "for country in df[\"Country ISO3\"].unique():\n", " subset = df[df[\"Country ISO3\"] == country]\n", " female = subset[subset[\"Sex\"] == \"Female\"]\n", " male = subset[subset[\"Sex\"] == \"Male\"]\n", " \n", " fig.add_trace(go.Scatter(x=female[\"Country ISO3\"], y=female[\"Value\"],\n", " marker = dict(color=\"purple\",\n", " symbol=\"circle\",\n", " size=7)\n", " ))\n", " fig.add_trace(go.Scatter(x=male[\"Country ISO3\"], y=male[\"Value\"],\n", " marker = dict(color=\"green\",\n", " symbol=\"diamond\",\n", " size=7,\n", " )\n", " ))\n", " \n", "fig.update_layout(title=\"Female/Male as a share of all 16-24 year-olds who can program\",\n", " width=900, height=500)\n", "\n", "fig.update_layout(showlegend=False)\n", "\n", "fig.show()\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "4. Rotate the x-axis text by using the Figure method `update_layout` as we did before" ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [ { "data": { "application/vnd.plotly.v1+json": { "config": { "plotlyServerURL": "https://plot.ly" }, "data": [ { "marker": { "color": "gray" }, "type": "scatter", "x": [ "GRC", "GRC" ], "y": [ 6.3402, 6.1347 ] }, { "marker": { "color": "purple", "size": 7, "symbol": "circle" }, "type": "scatter", "x": [ "GRC" ], "y": [ 6.3402 ] }, { "marker": { "color": "green", "size": 7, "symbol": "diamond" }, "type": "scatter", "x": [ "GRC" ], "y": [ 6.1347 ] }, { "marker": { "color": "gray" }, "type": "scatter", "x": [ "ITA", "ITA" ], "y": [ 9.8221, 17.7687 ] }, { "marker": { "color": "purple", "size": 7, "symbol": "circle" }, "type": "scatter", "x": [ "ITA" ], "y": [ 9.8221 ] }, { "marker": { "color": "green", "size": 7, "symbol": "diamond" }, "type": "scatter", "x": [ "ITA" ], "y": [ 17.7687 ] }, { "marker": { "color": "gray" }, "type": "scatter", "x": [ "MEX", "MEX" ], "y": [ 13.39843612, 11.7919203 ] }, { "marker": { "color": "purple", "size": 7, "symbol": "circle" }, "type": "scatter", "x": [ "MEX" ], "y": [ 11.7919203 ] }, { "marker": { "color": "green", "size": 7, "symbol": "diamond" }, "type": "scatter", "x": [ "MEX" ], "y": [ 13.39843612 ] }, { "marker": { "color": "gray" }, "type": "scatter", "x": [ "NOR", "NOR" ], "y": [ 20.6612, 28.6765 ] }, { "marker": { "color": "purple", "size": 7, "symbol": "circle" }, "type": "scatter", "x": [ "NOR" ], "y": [ 20.6612 ] }, { "marker": { "color": "green", "size": 7, "symbol": "diamond" }, "type": "scatter", "x": [ "NOR" ], "y": [ 28.6765 ] }, { "marker": { "color": "gray" }, "type": "scatter", "x": [ "SWE", "SWE" ], "y": [ 22.0652, 4.9019 ] }, { "marker": { "color": "purple", "size": 7, "symbol": "circle" }, "type": "scatter", "x": [ "SWE" ], "y": [ 4.9019 ] }, { "marker": { "color": "green", "size": 7, "symbol": "diamond" }, "type": "scatter", "x": [ "SWE" ], "y": [ 22.0652 ] }, { "marker": { "color": "gray" }, "type": "scatter", "x": [ "CZE", "CZE" ], "y": [ 9.7562, 13.1687 ] }, { "marker": { "color": "purple", "size": 7, "symbol": "circle" }, "type": "scatter", "x": [ "CZE" ], "y": [ 9.7562 ] }, { "marker": { "color": "green", "size": 7, "symbol": "diamond" }, "type": "scatter", "x": [ "CZE" ], "y": [ 13.1687 ] }, { "marker": { "color": "gray" }, "type": "scatter", "x": [ "EU27", "EU27" ], "y": [ 19.1101, 9.2549 ] }, { "marker": { "color": "purple", "size": 7, "symbol": "circle" }, "type": "scatter", "x": [ "EU27" ], "y": [ 9.2549 ] }, { "marker": { "color": "green", "size": 7, "symbol": "diamond" }, "type": "scatter", "x": [ "EU27" ], "y": [ 19.1101 ] }, { "marker": { "color": "gray" }, "type": "scatter", "x": [ "GBR", "GBR" ], "y": [ 12.4069, 31.4415 ] }, { "marker": { "color": "purple", "size": 7, "symbol": "circle" }, "type": "scatter", "x": [ "GBR" ], "y": [ 12.4069 ] }, { "marker": { "color": "green", "size": 7, "symbol": "diamond" }, "type": "scatter", "x": [ "GBR" ], "y": [ 31.4415 ] }, { "marker": { "color": "gray" }, "type": "scatter", "x": [ "ROU", "ROU" ], "y": [ 1.6474, 5.27 ] }, { "marker": { "color": "purple", "size": 7, "symbol": "circle" }, "type": "scatter", "x": [ "ROU" ], "y": [ 1.6474 ] }, { "marker": { "color": "green", "size": 7, "symbol": "diamond" }, "type": "scatter", "x": [ "ROU" ], "y": [ 5.27 ] }, { "marker": { "color": "gray" }, "type": "scatter", "x": [ "LVA", "LVA" ], "y": [ 14.1613, 6.5019 ] }, { "marker": { "color": "purple", "size": 7, "symbol": "circle" }, "type": "scatter", "x": [ "LVA" ], "y": [ 6.5019 ] }, { "marker": { "color": "green", "size": 7, "symbol": "diamond" }, "type": "scatter", "x": [ "LVA" ], "y": [ 14.1613 ] }, { "marker": { "color": "gray" }, "type": "scatter", "x": [ "OECD", "OECD" ], "y": [ 9.935724682068964, 20.10365410551724 ] }, { "marker": { "color": "purple", "size": 7, "symbol": "circle" }, "type": "scatter", "x": [ "OECD" ], "y": [ 9.935724682068964 ] }, { "marker": { "color": "green", "size": 7, "symbol": "diamond" }, "type": "scatter", "x": [ "OECD" ], "y": [ 20.10365410551724 ] }, { "marker": { "color": "gray" }, "type": "scatter", "x": [ "BGR", "BGR" ], "y": [ 2.6228, 1.3558 ] }, { "marker": { "color": "purple", "size": 7, "symbol": "circle" }, "type": "scatter", "x": [ "BGR" ], "y": [ 1.3558 ] }, { "marker": { "color": "green", "size": 7, "symbol": "diamond" }, "type": "scatter", "x": [ "BGR" ], "y": [ 2.6228 ] }, { "marker": { "color": "gray" }, "type": "scatter", "x": [ "CHE", "CHE" ], "y": [ 28.2142, 14.334 ] }, { "marker": { "color": "purple", "size": 7, "symbol": "circle" }, "type": "scatter", "x": [ "CHE" ], "y": [ 14.334 ] }, { "marker": { "color": "green", "size": 7, "symbol": "diamond" }, "type": "scatter", "x": [ "CHE" ], "y": [ 28.2142 ] }, { "marker": { "color": "gray" }, "type": "scatter", "x": [ "KOR", "KOR" ], "y": [ 12.53037175, 11.40916904 ] }, { "marker": { "color": "purple", "size": 7, "symbol": "circle" }, "type": "scatter", "x": [ "KOR" ], "y": [ 12.53037175 ] }, { "marker": { "color": "green", "size": 7, "symbol": "diamond" }, "type": "scatter", "x": [ "KOR" ], "y": [ 11.40916904 ] }, { "marker": { "color": "gray" }, "type": "scatter", "x": [ "AUT", "AUT" ], "y": [ 5.4433, 23.528 ] }, { "marker": { "color": "purple", "size": 7, "symbol": "circle" }, "type": "scatter", "x": [ "AUT" ], "y": [ 5.4433 ] }, { "marker": { "color": "green", "size": 7, "symbol": "diamond" }, "type": "scatter", "x": [ "AUT" ], "y": [ 23.528 ] }, { "marker": { "color": "gray" }, "type": "scatter", "x": [ "TUR", "TUR" ], "y": [ 7.0849, 3.3736 ] }, { "marker": { "color": "purple", "size": 7, "symbol": "circle" }, "type": "scatter", "x": [ "TUR" ], "y": [ 3.3736 ] }, { "marker": { "color": "green", "size": 7, "symbol": "diamond" }, "type": "scatter", "x": [ "TUR" ], "y": [ 7.0849 ] }, { "marker": { "color": "gray" }, "type": "scatter", "x": [ "LUX", "LUX" ], "y": [ 6.8359, 19.0381 ] }, { "marker": { "color": "purple", "size": 7, "symbol": "circle" }, "type": "scatter", "x": [ "LUX" ], "y": [ 6.8359 ] }, { "marker": { "color": "green", "size": 7, "symbol": "diamond" }, "type": "scatter", "x": [ "LUX" ], "y": [ 19.0381 ] }, { "marker": { "color": "gray" }, "type": "scatter", "x": [ "IRL", "IRL" ], "y": [ 12.8749, 12.6004 ] }, { "marker": { "color": "purple", "size": 7, "symbol": "circle" }, "type": "scatter", "x": [ "IRL" ], "y": [ 12.8749 ] }, { "marker": { "color": "green", "size": 7, "symbol": "diamond" }, "type": "scatter", "x": [ "IRL" ], "y": [ 12.6004 ] }, { "marker": { "color": "gray" }, "type": "scatter", "x": [ "LTU", "LTU" ], "y": [ 11.5083, 14.7388 ] }, { "marker": { "color": "purple", "size": 7, "symbol": "circle" }, "type": "scatter", "x": [ "LTU" ], "y": [ 11.5083 ] }, { "marker": { "color": "green", "size": 7, "symbol": "diamond" }, "type": "scatter", "x": [ "LTU" ], "y": [ 14.7388 ] }, { "marker": { "color": "gray" }, "type": "scatter", "x": [ "FRA", "FRA" ], "y": [ 25.1185, 12.8304 ] }, { "marker": { "color": "purple", "size": 7, "symbol": "circle" }, "type": "scatter", "x": [ "FRA" ], "y": [ 12.8304 ] }, { "marker": { "color": "green", "size": 7, "symbol": "diamond" }, "type": "scatter", "x": [ "FRA" ], "y": [ 25.1185 ] }, { "marker": { "color": "gray" }, "type": "scatter", "x": [ "HRV", "HRV" ], "y": [ 3.4155, 27.047 ] }, { "marker": { "color": "purple", "size": 7, "symbol": "circle" }, "type": "scatter", "x": [ "HRV" ], "y": [ 3.4155 ] }, { "marker": { "color": "green", "size": 7, "symbol": "diamond" }, "type": "scatter", "x": [ "HRV" ], "y": [ 27.047 ] }, { "marker": { "color": "gray" }, "type": "scatter", "x": [ "FIN", "FIN" ], "y": [ 9.9121, 30.2333 ] }, { "marker": { "color": "purple", "size": 7, "symbol": "circle" }, "type": "scatter", "x": [ "FIN" ], "y": [ 9.9121 ] }, { "marker": { "color": "green", "size": 7, "symbol": "diamond" }, "type": "scatter", "x": [ "FIN" ], "y": [ 30.2333 ] }, { "marker": { "color": "gray" }, "type": "scatter", "x": [ "PRT", "PRT" ], "y": [ 19.6454, 31.9929 ] }, { "marker": { "color": "purple", "size": 7, "symbol": "circle" }, "type": "scatter", "x": [ "PRT" ], "y": [ 19.6454 ] }, { "marker": { "color": "green", "size": 7, "symbol": "diamond" }, "type": "scatter", "x": [ "PRT" ], "y": [ 31.9929 ] }, { "marker": { "color": "gray" }, "type": "scatter", "x": [ "COL", "COL" ], "y": [ 12.1739402, 9.69739797 ] }, { "marker": { "color": "purple", "size": 7, "symbol": "circle" }, "type": "scatter", "x": [ "COL" ], "y": [ 9.69739797 ] }, { "marker": { "color": "green", "size": 7, "symbol": "diamond" }, "type": "scatter", "x": [ "COL" ], "y": [ 12.1739402 ] }, { "marker": { "color": "gray" }, "type": "scatter", "x": [ "HUN", "HUN" ], "y": [ 17.9011, 6.0922 ] }, { "marker": { "color": "purple", "size": 7, "symbol": "circle" }, "type": "scatter", "x": [ "HUN" ], "y": [ 6.0922 ] }, { "marker": { "color": "green", "size": 7, "symbol": "diamond" }, "type": "scatter", "x": [ "HUN" ], "y": [ 17.9011 ] }, { "marker": { "color": "gray" }, "type": "scatter", "x": [ "DEU", "DEU" ], "y": [ 13.7205, 4.8557 ] }, { "marker": { "color": "purple", "size": 7, "symbol": "circle" }, "type": "scatter", "x": [ "DEU" ], "y": [ 4.8557 ] }, { "marker": { "color": "green", "size": 7, "symbol": "diamond" }, "type": "scatter", "x": [ "DEU" ], "y": [ 13.7205 ] }, { "marker": { "color": "gray" }, "type": "scatter", "x": [ "BEL", "BEL" ], "y": [ 4.7314, 17.4764 ] }, { "marker": { "color": "purple", "size": 7, "symbol": "circle" }, "type": "scatter", "x": [ "BEL" ], "y": [ 4.7314 ] }, { "marker": { "color": "green", "size": 7, "symbol": "diamond" }, "type": "scatter", "x": [ "BEL" ], "y": [ 17.4764 ] }, { "marker": { "color": "gray" }, "type": "scatter", "x": [ "ESP", "ESP" ], "y": [ 15.3839, 23.2493 ] }, { "marker": { "color": "purple", "size": 7, "symbol": "circle" }, "type": "scatter", "x": [ "ESP" ], "y": [ 15.3839 ] }, { "marker": { "color": "green", "size": 7, "symbol": "diamond" }, "type": "scatter", "x": [ "ESP" ], "y": [ 23.2493 ] }, { "marker": { "color": "gray" }, "type": "scatter", "x": [ "POL", "POL" ], "y": [ 14.9733, 7.708 ] }, { "marker": { "color": "purple", "size": 7, "symbol": "circle" }, "type": "scatter", "x": [ "POL" ], "y": [ 7.708 ] }, { "marker": { "color": "green", "size": 7, "symbol": "diamond" }, "type": "scatter", "x": [ "POL" ], "y": [ 14.9733 ] }, { "marker": { "color": "gray" }, "type": "scatter", "x": [ "DNK", "DNK" ], "y": [ 24.8467, 12.7882 ] }, { "marker": { "color": "purple", "size": 7, "symbol": "circle" }, "type": "scatter", "x": [ "DNK" ], "y": [ 12.7882 ] }, { "marker": { "color": "green", "size": 7, "symbol": "diamond" }, "type": "scatter", "x": [ "DNK" ], "y": [ 24.8467 ] }, { "marker": { "color": "gray" }, "type": "scatter", "x": [ "EST", "EST" ], "y": [ 28.469100000000005, 12.0603 ] }, { "marker": { "color": "purple", "size": 7, "symbol": "circle" }, "type": "scatter", "x": [ "EST" ], "y": [ 12.0603 ] }, { "marker": { "color": "green", "size": 7, "symbol": "diamond" }, "type": "scatter", "x": [ "EST" ], "y": [ 28.469100000000005 ] }, { "marker": { "color": "gray" }, "type": "scatter", "x": [ "ISL", "ISL" ], "y": [ 23.5752, 7.3378 ] }, { "marker": { "color": "purple", "size": 7, "symbol": "circle" }, "type": "scatter", "x": [ "ISL" ], "y": [ 7.3378 ] }, { "marker": { "color": "green", "size": 7, "symbol": "diamond" }, "type": "scatter", "x": [ "ISL" ], "y": [ 23.5752 ] }, { "marker": { "color": "gray" }, "type": "scatter", "x": [ "SVN", "SVN" ], "y": [ 19.5473, 9.3437 ] }, { "marker": { "color": "purple", "size": 7, "symbol": "circle" }, "type": "scatter", "x": [ "SVN" ], "y": [ 9.3437 ] }, { "marker": { "color": "green", "size": 7, "symbol": "diamond" }, "type": "scatter", "x": [ "SVN" ], "y": [ 19.5473 ] }, { "marker": { "color": "gray" }, "type": "scatter", "x": [ "EU28", "EU28" ], "y": [ 20.9232, 9.8872 ] }, { "marker": { "color": "purple", "size": 7, "symbol": "circle" }, "type": "scatter", "x": [ "EU28" ], "y": [ 9.8872 ] }, { "marker": { "color": "green", "size": 7, "symbol": "diamond" }, "type": "scatter", "x": [ "EU28" ], "y": [ 20.9232 ] }, { "marker": { "color": "gray" }, "type": "scatter", "x": [ "NLD", "NLD" ], "y": [ 11.4195, 30.2065 ] }, { "marker": { "color": "purple", "size": 7, "symbol": "circle" }, "type": "scatter", "x": [ "NLD" ], "y": [ 11.4195 ] }, { "marker": { "color": "green", "size": 7, "symbol": "diamond" }, "type": "scatter", "x": [ "NLD" ], "y": [ 30.2065 ] }, { "marker": { "color": "gray" }, "type": "scatter", "x": [ "SVK", "SVK" ], "y": [ 6.156, 14.5269 ] }, { "marker": { "color": "purple", "size": 7, "symbol": "circle" }, "type": "scatter", "x": [ "SVK" ], "y": [ 6.156 ] }, { "marker": { "color": "green", "size": 7, "symbol": "diamond" }, "type": "scatter", "x": [ "SVK" ], "y": [ 14.5269 ] }, { "marker": { "color": "gray" }, "type": "scatter", "x": [ "BRA", "BRA" ], "y": [ 5.43, 5.235 ] }, { "marker": { "color": "purple", "size": 7, "symbol": "circle" }, "type": "scatter", "x": [ "BRA" ], "y": [ 5.235 ] }, { "marker": { "color": "green", "size": 7, "symbol": "diamond" }, "type": "scatter", "x": [ "BRA" ], "y": [ 5.43 ] }, { "marker": { "color": "gray" }, "type": "scatter", "x": [ "CAN", "CAN" ], "y": [ 28.9, 12.04 ] }, { "marker": { "color": "purple", "size": 7, "symbol": "circle" }, "type": "scatter", "x": [ "CAN" ], "y": [ 12.04 ] }, { "marker": { "color": "green", "size": 7, "symbol": "diamond" }, "type": "scatter", "x": [ "CAN" ], "y": [ 28.9 ] }, { "marker": { "color": "gray" }, "type": "scatter", "x": [ "CHL", "CHL" ], "y": [ 15.21341732, 19.13282657 ] }, { "marker": { "color": "purple", "size": 7, "symbol": "circle" }, "type": "scatter", "x": [ "CHL" ], "y": [ 15.21341732 ] }, { "marker": { "color": "green", "size": 7, "symbol": "diamond" }, "type": "scatter", "x": [ "CHL" ], "y": [ 19.13282657 ] } ], "layout": { "height": 500, "showlegend": false, "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": "Female/Male as a share of all 16-24 year-olds who can program" }, "width": 900, "xaxis": { "tickangle": -90 } } } }, "metadata": {}, "output_type": "display_data" } ], "source": [ "fig = go.Figure()\n", "\n", "for country in df[\"Country ISO3\"].unique():\n", " subset = df[df[\"Country ISO3\"] == country]\n", " female = subset[subset[\"Sex\"] == \"Female\"]\n", " male = subset[subset[\"Sex\"] == \"Male\"]\n", " \n", " fig.add_trace(go.Scatter(x=subset[\"Country ISO3\"], y=subset[\"Value\"],\n", " marker = dict(color=\"gray\"\n", " )\n", " ))\n", " fig.add_trace(go.Scatter(x=female[\"Country ISO3\"], y=female[\"Value\"],\n", " marker = dict(color=\"purple\",\n", " symbol=\"circle\",\n", " size=7)\n", " ))\n", " fig.add_trace(go.Scatter(x=male[\"Country ISO3\"], y=male[\"Value\"],\n", " marker = dict(color=\"green\",\n", " symbol=\"diamond\",\n", " size=7,\n", " )\n", " ))\n", "\n", "fig.update_layout(title=\"Female/Male as a share of all 16-24 year-olds who can program\", \n", " xaxis={'tickangle':-90},\n", " width=900, height=500,\n", " showlegend=False)\n", "\n", "fig.show()" ] } ], "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 }