Scatter plot (2)
In the previous exercise, you saw that the higher GDP usually corresponds to a higher life expectancy. In other words, there is a positive correlation.
Do you think there's a relationship between population and life expectancy of a country? The list life_exp from the previous exercise is already available. In addition, now also pop is available, listing the corresponding populations for the countries in 2007. The populations are in millions of people.
Diese Übung ist Teil des Kurses
Intermediate Python
Anleitung zur Übung
- Start from scratch: import
matplotlib.pyplotasplt. - Build a scatter plot, where
popis mapped on the horizontal axis, andlife_expis mapped on the vertical axis. - Finish the script with
plt.show()to actually display the plot. Do you see a correlation?
Interaktive Übung
Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.
# Import package
# Build Scatter plot
# Show plot