Using Error Bars to Show Uncertainty

In this lesson, we will learn how to use error bars to show error or uncertainty.

What is errorbar?

Error bars are graphical representations of the variability of data. They are used to indicate the error or uncertainty in a reported measurement. Error bars give a general idea of how precise a measurement is. For example, say we want to give a prediction about car sales for the next 12 months, but we are not 100% sure about our prediction. In order to indicate this uncertainty, we would provide a relative possible error. Error bars often represent one standard deviation of uncertainty, one standard error, or a particular confidence interval (e.g., a 95% confidence interval).

In Matplotlib, errorbar() is used to give an error range based on our data. Below are some common used important parameters required by errorbar. You can refer to the for the full parameter list.

In Matplotlib, errorbar() is the function we use to give an error range based on our data. Below are some of the most commonly used parameters required by errorbar. The official Matplotlib site contains the full parameter list.

  • x,y: Defines the data location.
  • xerr,yerr: Sets the corresponding error to x, y.
  • fmt: Sets the format for the data points/data lines.
  • ecolor: Sets the color of the error line.
  • elinewidth: Sets the line width of the error bar.
  • uplims,lolims: It can be True or False. The default value is False. These arguments can be used to indicate that value gives only upper/lower limits.
  • capsize: Sets the length of the error bar caps in points.

Get hands-on with 1200+ tech skills courses.