Enhancing our GDP plot
The United Nations loved your previous plot - the legend really stands out and makes it easier to view the plot.
However, there are some interesting data points that are not easy to further analyze due to the limited information in the plot.
Your task is to enhance the plot of life_gdp
created in the last exercise to include more information in the hover and style it as requested.
Some of the code will be familiar from earlier in the chapter.
This exercise is part of the course
Introduction to Data Visualization with Plotly in Python
Exercise instructions
- Create a scatterplot using the
life_gdp
DataFrame, setting the x-axis to beLife expectancy
, the y-axis to beGDP Per Capita
and colors based onContinent
. - Add the columns
Continent
,Life expectancy
, andGDP Per Capita
to appear in the hover information. - Set the
Country
variable to be bold at the top of the hover information.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Create the scatterplot
fig = px.scatter(
____=____,
____=____,
y=____,
____='Continent',
# Add columns to the hover information
____=____,
# Add bold variable in hover information
____='Country'
)
# Show the plot
fig.show()