I have several values of a function at different x points. I want to plot the mean and std in python, like the answer of this SO question. I know this must be easy using mat
plt.errorbar can be used to plot x, y, error data (as opposed to the usual 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 accepts the same arguments as plt.plot with additional yerr and xerr which default to None (i.e. if you leave them blank it will act as plt.plot).
