{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Exploring the Gapminder Data set"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## How to do it\n",
"\n",
"1. Import the `plotly.express` module as `px`"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
"import plotly.express as px"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"2. Load the data set and check its type"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"pandas.core.frame.DataFrame"
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"gapminder = px.data.gapminder()\n",
"type(gapminder)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"3. Inspect the `DataFrame` using the method `head` and `tail`"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"
\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" country | \n",
" continent | \n",
" year | \n",
" lifeExp | \n",
" pop | \n",
" gdpPercap | \n",
" iso_alpha | \n",
" iso_num | \n",
"
\n",
" \n",
" \n",
" \n",
" 0 | \n",
" Afghanistan | \n",
" Asia | \n",
" 1952 | \n",
" 28.801 | \n",
" 8425333 | \n",
" 779.445314 | \n",
" AFG | \n",
" 4 | \n",
"
\n",
" \n",
" 1 | \n",
" Afghanistan | \n",
" Asia | \n",
" 1957 | \n",
" 30.332 | \n",
" 9240934 | \n",
" 820.853030 | \n",
" AFG | \n",
" 4 | \n",
"
\n",
" \n",
" 2 | \n",
" Afghanistan | \n",
" Asia | \n",
" 1962 | \n",
" 31.997 | \n",
" 10267083 | \n",
" 853.100710 | \n",
" AFG | \n",
" 4 | \n",
"
\n",
" \n",
" 3 | \n",
" Afghanistan | \n",
" Asia | \n",
" 1967 | \n",
" 34.020 | \n",
" 11537966 | \n",
" 836.197138 | \n",
" AFG | \n",
" 4 | \n",
"
\n",
" \n",
" 4 | \n",
" Afghanistan | \n",
" Asia | \n",
" 1972 | \n",
" 36.088 | \n",
" 13079460 | \n",
" 739.981106 | \n",
" AFG | \n",
" 4 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" country continent year lifeExp pop gdpPercap iso_alpha \\\n",
"0 Afghanistan Asia 1952 28.801 8425333 779.445314 AFG \n",
"1 Afghanistan Asia 1957 30.332 9240934 820.853030 AFG \n",
"2 Afghanistan Asia 1962 31.997 10267083 853.100710 AFG \n",
"3 Afghanistan Asia 1967 34.020 11537966 836.197138 AFG \n",
"4 Afghanistan Asia 1972 36.088 13079460 739.981106 AFG \n",
"\n",
" iso_num \n",
"0 4 \n",
"1 4 \n",
"2 4 \n",
"3 4 \n",
"4 4 "
]
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"gapminder.head()"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" country | \n",
" continent | \n",
" year | \n",
" lifeExp | \n",
" pop | \n",
" gdpPercap | \n",
" iso_alpha | \n",
" iso_num | \n",
"
\n",
" \n",
" \n",
" \n",
" 1699 | \n",
" Zimbabwe | \n",
" Africa | \n",
" 1987 | \n",
" 62.351 | \n",
" 9216418 | \n",
" 706.157306 | \n",
" ZWE | \n",
" 716 | \n",
"
\n",
" \n",
" 1700 | \n",
" Zimbabwe | \n",
" Africa | \n",
" 1992 | \n",
" 60.377 | \n",
" 10704340 | \n",
" 693.420786 | \n",
" ZWE | \n",
" 716 | \n",
"
\n",
" \n",
" 1701 | \n",
" Zimbabwe | \n",
" Africa | \n",
" 1997 | \n",
" 46.809 | \n",
" 11404948 | \n",
" 792.449960 | \n",
" ZWE | \n",
" 716 | \n",
"
\n",
" \n",
" 1702 | \n",
" Zimbabwe | \n",
" Africa | \n",
" 2002 | \n",
" 39.989 | \n",
" 11926563 | \n",
" 672.038623 | \n",
" ZWE | \n",
" 716 | \n",
"
\n",
" \n",
" 1703 | \n",
" Zimbabwe | \n",
" Africa | \n",
" 2007 | \n",
" 43.487 | \n",
" 12311143 | \n",
" 469.709298 | \n",
" ZWE | \n",
" 716 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" country continent year lifeExp pop gdpPercap iso_alpha \\\n",
"1699 Zimbabwe Africa 1987 62.351 9216418 706.157306 ZWE \n",
"1700 Zimbabwe Africa 1992 60.377 10704340 693.420786 ZWE \n",
"1701 Zimbabwe Africa 1997 46.809 11404948 792.449960 ZWE \n",
"1702 Zimbabwe Africa 2002 39.989 11926563 672.038623 ZWE \n",
"1703 Zimbabwe Africa 2007 43.487 12311143 469.709298 ZWE \n",
"\n",
" iso_num \n",
"1699 716 \n",
"1700 716 \n",
"1701 716 \n",
"1702 716 \n",
"1703 716 "
]
},
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"gapminder.tail()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"4. Use the method `describe` "
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" year | \n",
" lifeExp | \n",
" pop | \n",
" gdpPercap | \n",
" iso_num | \n",
"
\n",
" \n",
" \n",
" \n",
" count | \n",
" 1704.00000 | \n",
" 1704.000000 | \n",
" 1.704000e+03 | \n",
" 1704.000000 | \n",
" 1704.000000 | \n",
"
\n",
" \n",
" mean | \n",
" 1979.50000 | \n",
" 59.474439 | \n",
" 2.960121e+07 | \n",
" 7215.327081 | \n",
" 425.880282 | \n",
"
\n",
" \n",
" std | \n",
" 17.26533 | \n",
" 12.917107 | \n",
" 1.061579e+08 | \n",
" 9857.454543 | \n",
" 248.305709 | \n",
"
\n",
" \n",
" min | \n",
" 1952.00000 | \n",
" 23.599000 | \n",
" 6.001100e+04 | \n",
" 241.165876 | \n",
" 4.000000 | \n",
"
\n",
" \n",
" 25% | \n",
" 1965.75000 | \n",
" 48.198000 | \n",
" 2.793664e+06 | \n",
" 1202.060309 | \n",
" 208.000000 | \n",
"
\n",
" \n",
" 50% | \n",
" 1979.50000 | \n",
" 60.712500 | \n",
" 7.023596e+06 | \n",
" 3531.846989 | \n",
" 410.000000 | \n",
"
\n",
" \n",
" 75% | \n",
" 1993.25000 | \n",
" 70.845500 | \n",
" 1.958522e+07 | \n",
" 9325.462346 | \n",
" 638.000000 | \n",
"
\n",
" \n",
" max | \n",
" 2007.00000 | \n",
" 82.603000 | \n",
" 1.318683e+09 | \n",
" 113523.132900 | \n",
" 894.000000 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" year lifeExp pop gdpPercap iso_num\n",
"count 1704.00000 1704.000000 1.704000e+03 1704.000000 1704.000000\n",
"mean 1979.50000 59.474439 2.960121e+07 7215.327081 425.880282\n",
"std 17.26533 12.917107 1.061579e+08 9857.454543 248.305709\n",
"min 1952.00000 23.599000 6.001100e+04 241.165876 4.000000\n",
"25% 1965.75000 48.198000 2.793664e+06 1202.060309 208.000000\n",
"50% 1979.50000 60.712500 7.023596e+06 3531.846989 410.000000\n",
"75% 1993.25000 70.845500 1.958522e+07 9325.462346 638.000000\n",
"max 2007.00000 82.603000 1.318683e+09 113523.132900 894.000000"
]
},
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"gapminder.describe()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"5. Make a scatter plot to visualize the relationship between GDP per capita and Life Expectancy for the oldes and the most recent year (i.e. 1952 and 2007)"
]
},
{
"cell_type": "code",
"execution_count": 25,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.plotly.v1+json": {
"config": {
"plotlyServerURL": "https://plot.ly"
},
"data": [
{
"hovertemplate": "gdpPercap=%{x}
lifeExp=%{y}",
"legendgroup": "",
"marker": {
"color": "#636efa",
"symbol": "circle"
},
"mode": "markers",
"name": "",
"orientation": "v",
"showlegend": false,
"type": "scatter",
"x": [
779.4453145,
1601.056136,
2449.008185,
3520.610273,
5911.315053,
10039.59564,
6137.076492,
9867.084765,
684.2441716,
8343.105126999999,
1062.7522,
2677.326347,
973.5331948,
851.2411407,
2108.944355,
2444.286648,
543.2552413,
339.2964587,
368.4692856,
1172.667655,
11367.16112,
1071.310713,
1178.665927,
3939.978789,
400.448611,
2144.115096,
1102.990936,
780.5423257,
2125.621418,
2627.0094710000008,
1388.594732,
3119.23652,
5586.53878,
6876.14025,
9692.385245,
2669.529475,
1397.717137,
3522.110717,
1418.822445,
3048.3029,
375.6431231,
328.9405571000001,
362.1462796,
6424.519071,
7029.809327,
4293.476475,
485.2306591,
7144.114393000002,
911.2989371,
3530.690067,
2428.2377690000008,
510.1964923000001,
299.850319,
1840.366939,
2194.926204,
3054.421209,
5263.673816,
7267.688428,
546.5657493,
749.6816546,
3035.326002,
4129.766056,
5210.280328,
4086.522128,
4931.404154999998,
2898.530881,
3216.956347,
1546.907807,
853.5409189999998,
1088.277758,
1030.592226,
108382.3529,
4834.804067,
298.8462121,
575.5729961000002,
2387.54806,
1443.011715,
369.1650802,
1831.132894,
452.3369807,
743.1159097,
1967.955707,
3478.125529,
786.5668575,
2647.585601,
1688.20357,
468.5260381,
331,
2423.780443,
545.8657228999998,
8941.571858,
10556.57566,
3112.363948,
761.879376,
1077.281856,
10095.42172,
1828.230307,
684.5971437999998,
2480.380334,
1952.308701,
3758.523437,
1272.880995,
4029.329699,
3068.319867,
3081.959785,
2718.885295,
3144.613186,
493.3238752,
879.5835855,
6459.554823,
1450.356983,
3581.459448,
879.7877358,
2315.138227,
5074.659104,
4215.041741,
1135.749842,
4725.295531000002,
3834.034742,
1083.53203,
1615.991129,
1148.376626,
8527.844662000001,
14734.23275,
1643.485354,
1206.947913,
716.6500721,
757.7974177,
859.8086567,
3023.271928,
1468.475631,
1969.10098,
734.753484,
9979.508487,
13990.482080000002,
5716.766744,
7689.799761,
605.0664917,
1515.5923289999996,
781.7175761,
1147.388831,
406.8841148
],
"xaxis": "x",
"y": [
28.801,
55.23,
43.077,
30.015,
62.485,
69.12,
66.8,
50.93899999999999,
37.484,
68,
38.223,
40.414,
53.82,
47.622,
50.917,
59.6,
31.975,
39.031,
39.417,
38.523,
68.75,
35.463,
38.092,
54.745,
44,
50.643,
40.715,
39.143,
42.111,
57.206,
40.477,
61.21,
59.42100000000001,
66.87,
70.78,
34.812,
45.928,
48.357,
41.893,
45.262,
34.482,
35.92800000000001,
34.078,
66.55,
67.41,
37.003,
30,
67.5,
43.149,
65.86,
42.023,
33.609,
32.5,
37.579,
41.912,
60.96,
64.03,
72.49,
37.37300000000001,
37.468,
44.869,
45.32,
66.91,
65.39,
65.94,
58.53,
63.03,
43.158,
42.27,
50.056,
47.453,
55.565,
55.928,
42.13800000000001,
38.48,
42.723,
36.681,
36.256,
48.463,
33.685,
40.543,
50.986,
50.789,
42.244,
59.164,
42.87300000000001,
31.286,
36.319,
41.725,
36.157,
72.13,
69.39,
42.31399999999999,
37.444,
36.324,
72.67,
37.578,
43.43600000000001,
55.191,
62.649,
43.902,
47.752,
61.31,
59.82,
64.28,
52.724,
61.05,
40,
46.471,
39.875,
37.278,
57.996,
30.331,
60.396,
64.36,
65.57,
32.978,
45.00899999999999,
64.94,
57.593,
38.635,
41.407,
71.86,
69.62,
45.883,
58.5,
41.215,
50.848,
38.596,
59.1,
44.6,
43.585,
39.978,
69.18,
68.44,
66.071,
55.088,
40.412,
43.16,
32.548,
42.038,
48.451
],
"yaxis": "y"
}
],
"layout": {
"legend": {
"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": "gdpPercap"
}
},
"yaxis": {
"anchor": "x",
"domain": [
0,
1
],
"title": {
"text": "lifeExp"
}
}
}
}
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"fig = px.scatter(gapminder[gapminder.year == 1952], x='gdpPercap', y='lifeExp')\n",
"fig.show()"
]
},
{
"cell_type": "code",
"execution_count": 24,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.plotly.v1+json": {
"config": {
"plotlyServerURL": "https://plot.ly"
},
"data": [
{
"hovertemplate": "gdpPercap=%{x}
lifeExp=%{y}",
"legendgroup": "",
"marker": {
"color": "#636efa",
"symbol": "circle"
},
"mode": "markers",
"name": "",
"orientation": "v",
"showlegend": false,
"type": "scatter",
"x": [
974.5803384,
5937.029525999998,
6223.367465,
4797.231267,
12779.37964,
34435.367439999995,
36126.4927,
29796.04834,
1391.253792,
33692.60508,
1441.284873,
3822.137084,
7446.298803,
12569.85177,
9065.800825,
10680.79282,
1217.032994,
430.0706916,
1713.778686,
2042.09524,
36319.23501,
706.016537,
1704.063724,
13171.63885,
4959.114854,
7006.580419,
986.1478792,
277.5518587,
3632.557798,
9645.06142,
1544.750112,
14619.222719999998,
8948.102923,
22833.30851,
35278.41874,
2082.4815670000007,
6025.3747520000015,
6873.262326000001,
5581.180998,
5728.353514,
12154.08975,
641.3695236000002,
690.8055759,
33207.0844,
30470.0167,
13206.48452,
752.7497265,
32170.37442,
1327.60891,
27538.41188,
5186.050003,
942.6542111,
579.2317429999998,
1201.637154,
3548.3308460000007,
39724.97867,
18008.94444,
36180.78919,
2452.210407,
3540.651564,
11605.71449,
4471.061906,
40675.99635,
25523.2771,
28569.7197,
7320.8802620000015,
31656.06806,
4519.461171,
1463.249282,
1593.06548,
23348.139730000006,
47306.98978,
10461.05868,
1569.331442,
414.5073415,
12057.49928,
1044.770126,
759.3499101,
12451.6558,
1042.581557,
1803.151496,
10956.99112,
11977.57496,
3095.7722710000007,
9253.896111,
3820.17523,
823.6856205,
944,
4811.060429,
1091.359778,
36797.93332,
25185.00911,
2749.320965,
619.6768923999998,
2013.977305,
49357.19017,
22316.19287,
2605.94758,
9809.185636,
4172.838464,
7408.905561,
3190.481016,
15389.924680000002,
20509.64777,
19328.70901,
7670.122558,
10808.47561,
863.0884639000002,
1598.435089,
21654.83194,
1712.472136,
9786.534714,
862.5407561000002,
47143.17964,
18678.31435,
25768.25759,
926.1410683,
9269.657808,
28821.0637,
3970.095407,
2602.394995,
4513.480643,
33859.74835,
37506.41907,
4184.548089,
28718.27684,
1107.482182,
7458.396326999998,
882.9699437999999,
18008.50924,
7092.923025,
8458.276384,
1056.380121,
33203.26128,
42951.65309,
10611.46299,
11415.80569,
2441.576404,
3025.349798,
2280.769906,
1271.211593,
469.70929810000007
],
"xaxis": "x",
"y": [
43.828,
76.423,
72.301,
42.731,
75.32,
81.235,
79.829,
75.635,
64.062,
79.441,
56.728,
65.554,
74.852,
50.728,
72.39,
73.005,
52.295,
49.58,
59.723,
50.43,
80.653,
44.74100000000001,
50.651,
78.553,
72.961,
72.889,
65.152,
46.462,
55.322,
78.782,
48.328,
75.748,
78.273,
76.486,
78.332,
54.791,
72.235,
74.994,
71.33800000000002,
71.878,
51.57899999999999,
58.04,
52.947,
79.313,
80.657,
56.735,
59.448,
79.406,
60.022,
79.483,
70.259,
56.007,
46.38800000000001,
60.916,
70.19800000000001,
82.208,
73.33800000000002,
81.757,
64.69800000000001,
70.65,
70.964,
59.545,
78.885,
80.745,
80.546,
72.567,
82.603,
72.535,
54.11,
67.297,
78.623,
77.58800000000002,
71.993,
42.592,
45.678,
73.952,
59.44300000000001,
48.303,
74.241,
54.467,
64.164,
72.801,
76.195,
66.803,
74.543,
71.164,
42.082,
62.069,
52.90600000000001,
63.785,
79.762,
80.204,
72.899,
56.867,
46.859,
80.196,
75.64,
65.483,
75.53699999999998,
71.752,
71.421,
71.688,
75.563,
78.098,
78.74600000000002,
76.442,
72.476,
46.242,
65.528,
72.777,
63.062,
74.002,
42.56800000000001,
79.972,
74.663,
77.926,
48.159,
49.339,
80.941,
72.396,
58.556,
39.613,
80.884,
81.70100000000002,
74.143,
78.4,
52.517,
70.616,
58.42,
69.819,
73.923,
71.777,
51.542,
79.425,
78.242,
76.384,
73.747,
74.249,
73.422,
62.698,
42.38399999999999,
43.487
],
"yaxis": "y"
}
],
"layout": {
"legend": {
"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": "gdpPercap"
}
},
"yaxis": {
"anchor": "x",
"domain": [
0,
1
],
"title": {
"text": "lifeExp"
}
}
}
}
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"fig = px.scatter(gapminder[gapminder.year == 2007], x='gdpPercap', y='lifeExp')\n",
"fig.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"6. Enhance the scatter plot by adding color the dots according to the continent."
]
},
{
"cell_type": "code",
"execution_count": 26,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.plotly.v1+json": {
"config": {
"plotlyServerURL": "https://plot.ly"
},
"data": [
{
"hovertemplate": "continent=Asia
gdpPercap=%{x}
lifeExp=%{y}",
"legendgroup": "Asia",
"marker": {
"color": "#636efa",
"symbol": "circle"
},
"mode": "markers",
"name": "Asia",
"orientation": "v",
"showlegend": true,
"type": "scatter",
"x": [
974.5803384,
29796.04834,
1391.253792,
1713.778686,
4959.114854,
39724.97867,
2452.210407,
3540.651564,
11605.71449,
4471.061906,
25523.2771,
31656.06806,
4519.461171,
1593.06548,
23348.139730000006,
47306.98978,
10461.05868,
12451.6558,
3095.7722710000007,
944,
1091.359778,
22316.19287,
2605.94758,
3190.481016,
21654.83194,
47143.17964,
3970.095407,
4184.548089,
28718.27684,
7458.396326999998,
2441.576404,
3025.349798,
2280.769906
],
"xaxis": "x",
"y": [
43.828,
75.635,
64.062,
59.723,
72.961,
82.208,
64.69800000000001,
70.65,
70.964,
59.545,
80.745,
82.603,
72.535,
67.297,
78.623,
77.58800000000002,
71.993,
74.241,
66.803,
62.069,
63.785,
75.64,
65.483,
71.688,
72.777,
79.972,
72.396,
74.143,
78.4,
70.616,
74.249,
73.422,
62.698
],
"yaxis": "y"
},
{
"hovertemplate": "continent=Europe
gdpPercap=%{x}
lifeExp=%{y}",
"legendgroup": "Europe",
"marker": {
"color": "#EF553B",
"symbol": "circle"
},
"mode": "markers",
"name": "Europe",
"orientation": "v",
"showlegend": true,
"type": "scatter",
"x": [
5937.029525999998,
36126.4927,
33692.60508,
7446.298803,
10680.79282,
14619.222719999998,
22833.30851,
35278.41874,
33207.0844,
30470.0167,
32170.37442,
27538.41188,
18008.94444,
36180.78919,
40675.99635,
28569.7197,
9253.896111,
36797.93332,
49357.19017,
15389.924680000002,
20509.64777,
10808.47561,
9786.534714,
18678.31435,
25768.25759,
28821.0637,
33859.74835,
37506.41907,
8458.276384,
33203.26128
],
"xaxis": "x",
"y": [
76.423,
79.829,
79.441,
74.852,
73.005,
75.748,
76.486,
78.332,
79.313,
80.657,
79.406,
79.483,
73.33800000000002,
81.757,
78.885,
80.546,
74.543,
79.762,
80.196,
75.563,
78.098,
72.476,
74.002,
74.663,
77.926,
80.941,
80.884,
81.70100000000002,
71.777,
79.425
],
"yaxis": "y"
},
{
"hovertemplate": "continent=Africa
gdpPercap=%{x}
lifeExp=%{y}",
"legendgroup": "Africa",
"marker": {
"color": "#00cc96",
"symbol": "circle"
},
"mode": "markers",
"name": "Africa",
"orientation": "v",
"showlegend": true,
"type": "scatter",
"x": [
6223.367465,
4797.231267,
1441.284873,
12569.85177,
1217.032994,
430.0706916,
2042.09524,
706.016537,
1704.063724,
986.1478792,
277.5518587,
3632.557798,
1544.750112,
2082.4815670000007,
5581.180998,
12154.08975,
641.3695236000002,
690.8055759,
13206.48452,
752.7497265,
1327.60891,
942.6542111,
579.2317429999998,
1463.249282,
1569.331442,
414.5073415,
12057.49928,
1044.770126,
759.3499101,
1042.581557,
1803.151496,
10956.99112,
3820.17523,
823.6856205,
4811.060429,
619.6768923999998,
2013.977305,
7670.122558,
863.0884639000002,
1598.435089,
1712.472136,
862.5407561000002,
926.1410683,
9269.657808,
2602.394995,
4513.480643,
1107.482182,
882.9699437999999,
7092.923025,
1056.380121,
1271.211593,
469.70929810000007
],
"xaxis": "x",
"y": [
72.301,
42.731,
56.728,
50.728,
52.295,
49.58,
50.43,
44.74100000000001,
50.651,
65.152,
46.462,
55.322,
48.328,
54.791,
71.33800000000002,
51.57899999999999,
58.04,
52.947,
56.735,
59.448,
60.022,
56.007,
46.38800000000001,
54.11,
42.592,
45.678,
73.952,
59.44300000000001,
48.303,
54.467,
64.164,
72.801,
71.164,
42.082,
52.90600000000001,
56.867,
46.859,
76.442,
46.242,
65.528,
63.062,
42.56800000000001,
48.159,
49.339,
58.556,
39.613,
52.517,
58.42,
73.923,
51.542,
42.38399999999999,
43.487
],
"yaxis": "y"
},
{
"hovertemplate": "continent=Americas
gdpPercap=%{x}
lifeExp=%{y}",
"legendgroup": "Americas",
"marker": {
"color": "#ab63fa",
"symbol": "circle"
},
"mode": "markers",
"name": "Americas",
"orientation": "v",
"showlegend": true,
"type": "scatter",
"x": [
12779.37964,
3822.137084,
9065.800825,
36319.23501,
13171.63885,
7006.580419,
9645.06142,
8948.102923,
6025.3747520000015,
6873.262326000001,
5728.353514,
5186.050003,
1201.637154,
3548.3308460000007,
7320.8802620000015,
11977.57496,
2749.320965,
9809.185636,
4172.838464,
7408.905561,
19328.70901,
18008.50924,
42951.65309,
10611.46299,
11415.80569
],
"xaxis": "x",
"y": [
75.32,
65.554,
72.39,
80.653,
78.553,
72.889,
78.782,
78.273,
72.235,
74.994,
71.878,
70.259,
60.916,
70.19800000000001,
72.567,
76.195,
72.899,
75.53699999999998,
71.752,
71.421,
78.74600000000002,
69.819,
78.242,
76.384,
73.747
],
"yaxis": "y"
},
{
"hovertemplate": "continent=Oceania
gdpPercap=%{x}
lifeExp=%{y}",
"legendgroup": "Oceania",
"marker": {
"color": "#FFA15A",
"symbol": "circle"
},
"mode": "markers",
"name": "Oceania",
"orientation": "v",
"showlegend": true,
"type": "scatter",
"x": [
34435.367439999995,
25185.00911
],
"xaxis": "x",
"y": [
81.235,
80.204
],
"yaxis": "y"
}
],
"layout": {
"legend": {
"title": {
"text": "continent"
},
"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": "gdpPercap"
}
},
"yaxis": {
"anchor": "x",
"domain": [
0,
1
],
"title": {
"text": "lifeExp"
}
}
}
}
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"fig = px.scatter(gapminder[gapminder.year == 2007], x='gdpPercap', y='lifeExp', color='continent')\n",
"fig.show()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.9"
}
},
"nbformat": 4,
"nbformat_minor": 2
}