我在不同的 x 点有多个函数值。我想在 python 中绘制平均值和标准差,就像答案一样这个问题 https://stackoverflow.com/questions/19797846/plot-mean-standard-deviation-standard-error-of-the-mean-and-confidence-interv。我知道使用 matplotlib 一定很容易,但我不知道可以做到这一点的函数名称。有人知道吗?
plt.errorbar http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.errorbar可用于绘制 x、y、误差数据(与通常的plt.plot
)
import matplotlib.pyplot as plt
import numpy as np
x = np.array([1, 2, 3, 4, 5])
y = np.power(x, 2) # Effectively y = x**2
e = np.array([1.5, 2.6, 3.7, 4.6, 5.5])
plt.errorbar(x, y, e, linestyle='None', marker='^')
plt.show()
plt.errorbar
接受与以下相同的参数plt.plot
与额外的yerr
and xerr
默认为“无”(即,如果将它们留空,它将充当plt.plot
).
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)