Python Pylab散点图误差条(每个点的误差都是唯一的)

标签 python matplotlib

我正在尝试 2 个数组的散点图,其中我有第三个数组,其中包含每个点的绝对误差(y 方向的误差)。我希望误差线介于(点 a - a 上的错误)和(点 a + a 上的错误)之间。有没有办法通过 pylab 实现这一点,如果没有关于我还能如何做到这一点的任何想法?

最佳答案

这几乎与其他答案一样,但您根本不需要 scatter 图,您可以简单地指定类似散点图的格式(fmt-参数)为errorbar :

import matplotlib.pyplot as plt
x = [1, 2, 3, 4]
y = [1, 4, 9, 16]
e = [0.5, 1., 1.5, 2.]
plt.errorbar(x, y, yerr=e, fmt='o')
plt.show()

结果:

enter image description here

可以在 plot 中找到可用的 fmt 参数列表。文档:

character   description
'-'     solid line style
'--'    dashed line style
'-.'    dash-dot line style
':'     dotted line style
'.'     point marker
','     pixel marker
'o'     circle marker
'v'     triangle_down marker
'^'     triangle_up marker
'<'     triangle_left marker
'>'     triangle_right marker
'1'     tri_down marker
'2'     tri_up marker
'3'     tri_left marker
'4'     tri_right marker
's'     square marker
'p'     pentagon marker
'*'     star marker
'h'     hexagon1 marker
'H'     hexagon2 marker
'+'     plus marker
'x'     x marker
'D'     diamond marker
'd'     thin_diamond marker
'|'     vline marker
'_'     hline marker

关于Python Pylab散点图误差条(每个点的误差都是唯一的),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22364565/

相关文章:

python - joblib.Parallel 用于嵌套列表理解

python - Pandas :如何在数据框中存储列表?

python - 如何可视化 Pandas 中的缺失值模式

python - 线性判别分析后仅绘制了 2 个簇,而不是 3 个

javascript - 在 Python 中从 Ajax 请求中提取数据

python - request.endpoint的内容[:5]

python - Unicode解码错误: 'ascii' codec can't decode byte 0xc3 in position 7601: ordinal not in range(128)

python - 如何使用 numpy 生成具有选定空间分布的噪声?

python - 在 python 中使用 matplotlib 制作自定义颜色图

python - matplotlib 中的背靠背直方图