GDP Per Capita vs Life Expectancy Scatter Plot
The same approach can be used for a different kind of plot, that is, the scatter plot. The below code shows how it is done. facet_col is used to split our plot into sub-plots of continent data like shown below.
Python3
import plotly.express as px gapminder = px.data.gapminder() gapminder.head( 15 ) fig = px.scatter( gapminder, x = "gdpPercap" , y = "lifeExp" , animation_frame = "year" , animation_group = "country" , size = "pop" , color = "continent" , hover_name = "country" , facet_col = "continent" , size_max = 45 , range_y = [ 25 , 90 ] ) fig.show() |
Output:
Animated Data Visualization using Plotly Express
Data Visualization is a big thing in the data science industry and displaying the proper statistics to a business or governments can help them immeasurably in improving their services. It is very painful to understand data from different times from multiple charts and make any sense of it. That is where the need for animated data visualizations lie. In this, article we are going to use Plotly Express for plotting and animating the data and datasets from Gapminder. We are going to look at different types of animation provided by Plotly Express.
Contact Us