带 pandas 的不对称错误栏 [英] Asymmetrical errorbar with pandas

查看:86
本文介绍了带 pandas 的不对称错误栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用熊猫绘制不对称的误差线.根据官方文档应该可以工作

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)

但是对于上下限(-0.2/+ 0.2而不是-0.2/+ 0.7),pandas都将错误栏显示为df[1]:

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

我在哪里出错?

我在Windows 7下将pandas v0.20.3与python v2.7.13一起使用.

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

推荐答案

您的yerr是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]]]

这篇关于带 pandas 的不对称错误栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆