An end-to-end data visualization project using Plotly Express and the Gapminder dataset, showcasing how to build interactive, animated, and insightful visualizations with minimal code.
This project demonstrates the power of modern data visualization using Plotly Express, a high-level interface for creating interactive visualizations in Python. Inspired by Hans Rosling’s iconic Gapminder presentation, this notebook explores global development trends such as:
- Life Expectancy
- GDP per Capita
- Population Growth
- Geographic Patterns
The project walks through progressively advanced visualizations, from simple bar charts to animated global maps.
Source: Gapminder dataset (built into Plotly Express)
Accessed via: px.data.gapminder()
Features include:
- Country
- Year
- Population (
pop) - GDP per capita (
gdpPercap) - Life expectancy (
lifeExp) - Continent
- ISO country codes (
iso_alpha)
- Imported required libraries (
pandas,plotly, etc.) - Loaded Gapminder dataset using Plotly Express
- Displayed dataset preview using
create_table
- Created bar charts for Canada’s population over time
- Enhanced visualization with:
- Color encoding (
lifeExp) - Hover data (
gdpPercap,lifeExp) - Custom labels
- Color encoding (
- Built scatter plots to explore the relationship between GDP and life expectancy
- Added:
- Color grouping by continent
- Automatic legend handling
- Extended scatter plots into bubble charts
- Features:
- Bubble size scaled by population
hover_nameto identify countries
- Enables intuitive exploration of outliers and trends
- Created facet plots by continent
- Applied logarithmic scaling on the x-axis (
log_x=True) - Built animated scatter plots:
animation_frame="year"animation_group="country"
- Added:
- Axis ranges for smooth animation
- Clean labels across the visualization
- Built animated choropleth maps
- Features:
- Life expectancy represented by color
- Time-based animation
- Multiple projections:
- Natural Earth
- Orthographic (globe view)
- Created:
- Line plots for life expectancy trends
- Area plots for population growth
- Used:
line_groupfor country-level tracking- Smooth curves (
line_shape="spline")
- Higher GDP per capita correlates with higher life expectancy, with diminishing returns at higher income levels.
- Clear global inequalities exist, with developing regions showing lower life expectancy and income compared to developed regions.
- Population growth trends vary significantly across countries, highlighting differences in economic development and demographic transitions.
- Python
- Pandas
- NumPy
- Plotly
- Plotly Express
- Plotly Graph Objects
- Interactive plots (zoom, hover, select)
- Animated visualizations over time
- Multi-dimensional encoding (color, size, facets)
- Geographic mapping capabilities
- Minimal code with powerful output