Warning: I'm very new to using python.
I'm trying to graph data using error bars but my data has different values for the error above and below the bar, i.e. 2+.75,2-.32.
import numpy as np
import matplotlib.pyplot as plt
# example data
x = (1,2,3,4)
y = (1,2,3,4)
# example variable error bar values
yerr = 0.2
plt.figure()
plt.errorbar(x, y, yerr,"r^")
plt.show()
But I want the error bar above the point to be a specific value like .17 and below the point to be a specific point like .3
Does anyone know how to do this?
Thanks!
解决方案
Like this:
plt.errorbar(x, y, np.array([[0.3]*len(x), [0.17]*len(x)]), fmt='r^')
Pass an array of shape (2,n) with the -errors on the first row and the +errors on the second