Code
import plotly.io as pio
pio.renderers.default = "plotly_mimetype+notebook_connected"Download this Jupyter notebook:
Click here to download the.ipynbfile
(Or use the “Download” button in the top right of the page if available.)
plotly.jsplotly.express (px): one function call per chart, works directly on data framesplotly.graph_objects (go): build a figure trace by trace for full controlconda install plotly or pip install plotlycountry, continent, year, lifeExp, pop, gdpPercappx.data.gapminder(), which also includes ISO country codes for maps(1704, 8)
| country | continent | year | lifeExp | pop | gdpPercap | iso_alpha | iso_num | |
|---|---|---|---|---|---|---|---|---|
| 0 | Afghanistan | Asia | 1952 | 28.801 | 8425333 | 779.445314 | AFG | 4 |
| 1 | Afghanistan | Asia | 1957 | 30.332 | 9240934 | 820.853030 | AFG | 4 |
| 2 | Afghanistan | Asia | 1962 | 31.997 | 10267083 | 853.100710 | AFG | 4 |
| 3 | Afghanistan | Asia | 1967 | 34.020 | 11537966 | 836.197138 | AFG | 4 |
| 4 | Afghanistan | Asia | 1972 | 36.088 | 13079460 | 739.981106 | AFG | 4 |