Data Visualization with Plotly and Seaborn: Explore the Gapminder Dataset with Plotly Express

Plotly Express is a high-level Python visualization library. Inspired by Seaborn and ggplot2, it was specifically designed to have a terse, consistent and easy-to-learn API: with just a single import, you can make richly interactive plots in just a single function call, including faceting, maps, animations, and trendlines. It comes with on-board datasets, color scales and themes.

In this project, we will explore the iconic Gapminder dataset.

Join for $9.99
Data Visualization with Plotly and Seaborn: Explore the Gapminder Dataset with Plotly Express

Task List


We will cover the following tasks in 42 minutes:


Loading the Data

In this task, we will first demo Hans Rosling’s visualization of the Gapminder data set. The interactive, animated visualization was shown to the audience of Hans’ Ted talk in 2007. It has gone one to become one of the most watched Ted talks of all time, and is a testament to the power of beautiful and informative data visualizations.

We will then be ntroduced to the project goals and learning outcomes. Once we are familiarized with the Rhyme interface, we begin working in Jupyter Notebook, a web-based interactive computational environment for creating notebook documents.


Quick Visualizations with Custom Bar Charts

Now that we have imported the data, we are free to use plotly express to explore various facets of this rich data set.

Plotly Express functions take as a first argument a tidy pandas.DataFrame. In this task, we will graph the population of Canada by year using a bar plot. In a bar plot, each row of the DataFrame is represented as a rectangular mark. We will also customize the bar plot using keyword arguments to color the bars according to the average life expectancy.


Plot Life Expectancy vs GDP per Capita

We will create a basic scatter plot showing life expectancy vs GDP per captita by country for 2007.

Next, we will break that down by continent, by coloring the points using the color argument, while px takes care of assigning the default colors, setting up the legend, etc.


Customize Interactive Bubble Charts

Each point in our last plot is a country. So to scale the points by the country population we simply pass in the size argument!

If we’re curious about the identity of a particular point, we can add a hover_name to display the country name. We will never again have to worry about what a particular outlier represents. We can simply mouse over the point we’re interested in and the hover_name will identify it for us!


Create Interactive Animations and Facet Plots

We are able to easily interact with the plots we have created so far. Try mousing over points, clicking or double-clicking on legend items, or using the “modebar” that appears when you move your mouse into the frame to control the behaviour click-drag interactions (zoom, pan, select).

We can also facet our plots to pick apart the continents, just as easily as coloring your points, with facet_col="continent", and let’s make the x-axis logarithmic to see things more clearly while we’re at it.

Maybe we’re interested in more than just 2007 want to see how this chart evolved over time. We can animate it by setting animation_frame="year" (and animation_group="country" to identify which circles match which ones across frames). We can provide prettier labels that get applied throughout the figure, in legends, axis titles and hovers. We can also provide some manual bounds so the animation looks nice throughout.


Represent Geographic Data as Animated Maps

As this is geographic data, we can also represent it as an animated map, which makes it clear that px can make way more than just scatter plots, and that this dataset is missing data for the former Soviet Union.

Watch Preview

Preview the instructions that you will follow along in a hands-on session in your browser.

Snehan Kekre

About the Host (Snehan Kekre)


Snehan hosts Machine Learning and Data Sciences projects at Rhyme. He is in his senior year of university at the Minerva Schools at KGI, studying Computer Science and Artificial Intelligence. When not applying computational and quantitative methods to identify the structures shaping the world around him, he can sometimes be seen trekking in the mountains of Nepal.



Frequently Asked Questions


In Rhyme, all projects are completely hands-on. You don't just passively watch someone else. You use the software directly while following the host's (Snehan Kekre) instructions. Using the software is the only way to achieve mastery. With the "Live Guide" option, you can ask for help and get immediate response.
Nothing! Just join through your web browser. Your host (Snehan Kekre) has already installed all required software and configured all data.
You can go to https://rhyme.com/for-companies, sign up for free, and follow this visual guide How to use Rhyme to create your own projects. If you have custom needs or company-specific environment, please email us at help@rhyme.com
Absolutely. We offer Rhyme for workgroups as well larger departments and companies. Universities, academies, and bootcamps can also buy Rhyme for their settings. You can select projects and trainings that are mission critical for you and, as well, author your own that reflect your own needs and tech environments. Please email us at help@rhyme.com
Rhyme's visual instructions are somewhat helpful for reading impairments. The Rhyme interface has features like resolution and zoom that are slightly helpful for visual impairment. And, we are currently developing a close-caption functionality to help with hearing impairment. Most of the accessibility options of the cloud desktop's operating system or the specific application can also be used in Rhyme. However, we still have a lot of work to do. If you have suggestions for accessibility, please email us at accessibility@rhyme.com
We started with windows and linux cloud desktops because they have the most flexibility in teaching any software (desktop or web). However, web applications like Salesforce can run directly through a virtual browser. And, others like Jupyter and RStudio can run on containers and be accessed by virtual browsers. We are currently working on such features where such web applications won't need to run through cloud desktops. But, the rest of the Rhyme learning, authoring, and monitoring interfaces will remain the same.
Please email us at help@rhyme.com and we'll respond to you within one business day.

Ready to join this 42 minutes session?

More Projects by Snehan Kekre