# Matplotlib: plot indicating the precision of measurements

I have some data with some margin of error and am using numpy arrays to plot that data. Assuming the precision is, let's say, 0.05 or 0.03grams, then the data will be something like

[4.0 $\pm$ 0.05, 3.05 $\pm$ 0.03]

How can I show this on my plot (either on the x axis or the y axis. If it's both, even better)?

I use pyplot and my OS is macOS

• Can you use error bars? See the documentation and this example. Welcome to the site! – Emre Oct 25 '17 at 23:37
• Thanks! Yeah, I think this pretty much solves my question, as simple as it seems. Should I answer to my own question? (I just read your profile) – evaristegd Oct 25 '17 at 23:57
• Yes, please. Try to make it self-contained, so users don't need to follow links (unlike my comment). – Emre Oct 26 '17 at 0:03
• It was just downvoted, so I think I'll just delete it. It was a very easy question anyways – evaristegd Oct 26 '17 at 0:08
• @EvaristeGD Or you can answer your own question and mark the answer correct ... so that it might come useful for someone in the future. – Kiritee Gak Oct 26 '17 at 0:49

## 1 Answer

One can use the matplotlib.axes.Axes.errorbar class.

From this example in the documentation:

# example error bar values that vary with x-position
error = 0.1 + 0.2 * x

fig, (ax0, ax1) = plt.subplots(nrows=2, sharex=True)
ax0.errorbar(x, y, yerr=error, fmt='-o')
ax0.set_title('variable, symmetric error')


Acknowledgments: Thanks to Emre!