Open oldoc63 opened 1 year ago
Each of the black lines is called an error bar. The taller the bar is, the more uncertain we are about the height of the blue bar. The horizontal lines at the top and bottom are called caps. They make it easier to read the error bars.
If we wanted to show an error of +/- 2, we would add the keyword yerr=2
to our plt.bar command. To make the caps wide an easy to read, we would add the keyword capsize=10
:
Like the list of x-axis labels, Matplotlib reads this in the same order as the list of y-values. So, the first index of your error list should correspond to the first index of your y-values list, and so on.
You've learned to represent data as bars of different heights. Sometimes, we need to visually communicate some sort of uncertainty in the heights of those bars. Here are some examples:
To display error visually in a bar chart, we often use error bars to show where each bar could be, taking errors into account.