python-2.7 - matplotlib.pyplot 中的阴影不确定性/误差区域

标签 python-2.7 matplotlib uncertainty

我正在寻找一种方法来绘制阴影错误区域而不是 Python 中的错误栏。

我知道有 matplotlib.pyplot.fill_between() 使用它您可以为 y 错误构建一个解决方法,但不包括 x 不确定性。

problem_description

有任何想法吗?不幸的是,我没有足够的声誉发表评论 here .

提前致谢!

编辑
matplotlib.pyplot.fill_betweenx()导致类似:

fill_between_problem1

编辑 2

此外,我认为它对于完全不确定的区域是不正确的。下面我画了我认为正确的形状 - 我希望,我在这里没有错......

problem_sketch

import numpy as np
import matplotlib.pyplot as plt

x = np.asarray([1.0, 2.0, 3.0, 4.0])
y = np.asarray([1.0, 2.3, 3.0, 4.0])
xerr = np.asarray([0.1, 0.7, 0.1, 0.1])
yerr = np.asarray([0.1, 0.9, 1.2, 0.1])

plt.errorbar(x, y, yerr, xerr)

plt.fill_between(x, y-yerr, y+yerr, facecolor='#F0F8FF', alpha=1.0, edgecolor='none')
plt.fill_betweenx(y,x-xerr, x+xerr, facecolor='#F0F8FF', alpha=1.0, edgecolor='#8F94CC', linewidth=1, linestyle='dashed')

plt.show()
# Red lines added with inkscape.

最佳答案

我让它与 fill_betweenx 一起工作功能:

import numpy as np
import matplotlib.pyplot as plt

x = np.asarray([1.0, 2.0, 3.0, 4.0, 5.0])
y = np.asarray([1.0, 2.0, 3.0, 4.0, 5.0])
xerr = np.asarray([0.2, 0.4, 0.6, 0.8, 1.0])
yerr = np.asarray([0.1, 0.2, 0.3, 0.4, 0.5])

plt.errorbar(x, y, yerr, xerr)

plt.fill_between(x, y-yerr, y+yerr,facecolor='r',alpha=0.5)
plt.fill_betweenx(y,x-xerr,x+xerr,facecolor='b',alpha=0.5)

plt.show()  

这导致了这个情节:

fill_between, fill_betweenx

编辑

在您的具体示例中,使用以下内容可能就足够了:
plt.fill_between(x, y-yerr, y+yerr,facecolor='#F0F8FF',alpha=1.0,edgecolor='none')
plt.fill_betweenx(y,x-xerr, x+xerr,facecolor='#F0F8FF',alpha=1.0,edgecolor='none')

这样,您就没有边缘,这些边缘会交叉并放弃这种“折叠”。此外,它可能会产生一个错误带的足够错觉。您必须同时使用 fill_betweenfill_betweenx , 尽管。

关于python-2.7 - matplotlib.pyplot 中的阴影不确定性/误差区域,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24823753/

相关文章:

c++ - 查找父节点在二叉树中的位置

python-2.7 - Python-docx - 如何更改表格字体大小?

python - 使用 Python 2.7.9 的 TWOSQRS SPOJ 给出运行时错误 (NZEC)

python - matplotlib: sys.exitfunc 错误

r - 如何计算 R 中随机森林回归模型的置信度

machine-learning - 在分类神经网络中应如何处理训练数据中的系统不确定性(向上和向下)?

python - 切片端点被无形地截断

python - 如何在 Pandas 中拆分列标题并正确导出到 Excel

python - Shapely 多边形与 Matplotlib 楔形的交集

python - 使用 matplotlib 创建全天空投影的好奇(坏?)行为