0

I want to plot asymmetrical errorbars with pandas. According to official docs this should work

df = pd.DataFrame([[1,0.2,0.7]]) fig, ax = plt.subplots() df[0].plot.bar(yerr=[df[1], df[2]], ax=ax) 

But pandas renders errorbar as df[1] for both lower and upper limits (-0.2/+0.2 istead of -0.2/+0.7):

enter image description here

Where do I make a mistake?

I use pandas v0.20.3 with python v2.7.13 under Windows 7.

0

1 Answer 1

4

Your yerr is 1D:

yerr=[df[1], df[2]] 

It needs to be 2D, specifically one row per data point and each row having two values for negative and positive error:

yerr=[[df[1], df[2]]] 
Sign up to request clarification or add additional context in comments.

1 Comment

actually either 1D or 2D seems to output the correct result in a newer version of pandas, I tested with pandas 1.2.4 and matplotlib 3.3.4

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.