0

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)

1 Answer 1

3

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')

enter image description here

Sign up to request clarification or add additional context in comments.

1 Comment

Works perfectly! Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.