oldoc63 / learningDS

Learning DS with Codecademy and Books
0 stars 0 forks source link

Error Bars #486

Open oldoc63 opened 1 year ago

oldoc63 commented 1 year ago

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.

oldoc63 commented 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:

oldoc63 commented 1 year ago

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.

oldoc63 commented 1 year ago
  1. For someone who is learning about the different drink types at MatplotSip, a bar chart of milk amounts in each drink may be useful. We have provided the ounces_of_milk list, which contains the amount of milk in each 12oz drink in the drinks list. Plot this information as a bar chart.
oldoc63 commented 1 year ago
  1. According to different barista styles and measurement errors, there might be variation on how much milk actually goes into each drink. We've included a list error, with and error of 10% on each amount of milk. Display this error as error bars on the bar graph.
oldoc63 commented 1 year ago
  1. Add caps of size 5 to your error bars.