Reputation: 89
How can I add asymmetric error bars to one data point using matplotlib python. Right now I have something like
x = 1
y = 2
yerr = 0.5
pl.errorbar(x, y, yerr=[yerr, 2*yerr],fmt='o')
but I get
In safezip, len(args[0])=1
but len(args[1])=2
Thanks!
(I tried the same plot line but with arrays for x and y and it works fine)
Upvotes: 0
Views: 5666
Reputation: 9726
It is not very well documented, but errorbar()
expects yerr
to be a 2xN array if you want asymmetrical errorbars. For example:
import matplotlib.pyplot as plt
fig = plt.figure()
pl = fig.add_subplot(1, 1, 1)
x = 1
y = 2
yerr = 0.5
pl.errorbar(x, y, yerr=[[yerr], [2*yerr]],fmt='o')
plt.savefig('t.png')
Upvotes: 3