Adding error-bars to a bar chart
Statistical plotting techniques add quantitative information for comparisons into the visualization. For example, in this exercise, we will add error bars that quantify not only the difference in the means of the height of medalists in the 2016 Olympic Games, but also the standard deviation of each of these groups, as a way to assess whether the difference is substantial relative to the variability within each group.
For the purpose of this exercise, you will have two DataFrames: mens_rowing holds data about the medalists in the rowing events and mens_gymnastics will hold information about the medalists in the gymnastics events.
Deze oefening maakt deel uit van de cursus
Introduction to Data Visualization with Matplotlib
Oefeninstructies
- Add a bar with size equal to the mean of the
"Height"column in themens_rowingDataFrame and an error-bar of its standard deviation. - Add another bar for the mean of the
"Height"column inmens_gymnasticswith an error-bar of its standard deviation. - Add a label to the the y-axis:
"Height (cm)".
Praktische interactieve oefening
Probeer deze oefening eens door deze voorbeeldcode in te vullen.
fig, ax = plt.subplots()
# Add a bar for the rowing "Height" column mean/std
ax.____("Rowing", ____, yerr=____)
# Add a bar for the gymnastics "Height" column mean/std
____
# Label the y-axis
____
plt.show()