Scatter plots
When you made bee swarm plots, box plots, and ECDF plots in previous exercises, you compared the petal lengths of different species of iris. But what if you want to compare two properties of a single species? This is exactly what we will do in this exercise. We will make a scatter plot of the petal length and width measurements of Anderson's Iris versicolor flowers. If the flower scales (that is, it preserves its proportion as it grows), we would expect the length and width to be correlated.
For your reference, the code used to produce the scatter plot in the video is provided below:
_ = plt.plot(total_votes/1000, dem_share, marker='.', linestyle='none')
_ = plt.xlabel('total votes (thousands)')
_ = plt.ylabel('percent of vote for Obama')
This exercise is part of the course
Statistical Thinking in Python (Part 1)
Exercise instructions
- Use
plt.plot()
with the appropriate keyword arguments to make a scatter plot of versicolor petal length (x-axis) versus petal width (y-axis). The variablesversicolor_petal_length
andversicolor_petal_width
are already in your namespace. Do not forget to use themarker='.'
andlinestyle='none'
keyword arguments. - Label the axes.
- Display the plot.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Make a scatter plot
# Label the axes
# Show the result