据我所知,matplotlib只是在为我的误差条绘制错误的值。我已经尽我所能简化了我的代码,到了硬编码的值和事情仍然是错误的。。。在下面的示例中,我通过scatter
绘制了完全相同的值,它们出现在我希望它们出现的地方-但是误差线离我们很远。我误解什么了吗?在
from matplotlib.pyplot import *
x = [1, 2, 3, 4, 5]
y = [5, 11, 22, 44, 88]
err = [[4.3, 10.1, 19.8, 40, 81.6],
[5.9, 13.6, 24.6, 48.5, 100.2]]
figure();
errorbar(x, y, yerr=err, label="data")
scatter(x, err[0], c='r', label="lower limit")
scatter(x, err[1], c='g', label="upper limit")
legend()
show()
正如@Bart在评论中指出的,matplotlib将
yerr
解释为相对于直线y坐标的一组+/-偏移量。来自the documentation:您可以通过取
y
和err
之间的绝对差异来获得所需的效果:误差线是相对于数据的,而且,两个+/-值都是正值(因此绝对误差):
相关问题 更多 >
编程相关推荐