I'm trying to plot a series with asymmetric error bars using pandas and matplotlib with the following code:
d = {'high_delta': {1: 0.6,
2: 0.1,
3: 0.2,
4: 0.1,
5: 0.1,
6: 0.1,
7: 0.1,
8: 0.1,
9: 0.2,
10: 0.1},
'low_delta': {1: 0.2,
2: 0.1,
3: 0.1,
4: 0.1,
5: 0.1,
6: 0.1,
7: 0.1,
8: 0.1,
9: 0.1,
10: 0.4},
'p_hat': {1: 0.2,
2: 0.1,
3: 0.3,
4: 0.3,
5: 0.1,
6: 0.3,
7: 0.2,
8: 0.2,
9: 0.1,
10: 0.8}}
df = pandas.DataFrame(d)
df['p_hat'].plot(yerr=df[['low_delta', 'high_delta']].T.values)
(df.p_hat + df.high_delta).plot(style='.')
(df.p_hat - df.low_delta).plot(style='*')
The lower bounds always seem to match what I would expect, but instead of adding the values on the upper bound it seems to be adding the values from the lower bound again.
How should the errors be passed into matplotlib so that the error bars are rendered correctly?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…