Closed
Description
The docs for errorbar
state:
xerr/yerr: [ scalar | N, Nx1, or 2xN array-like ] If a scalar number, len(N) array-like object, or an Nx1 array-like object, errorbars are drawn at +/-value relative to the data.
If a sequence of shape 2xN, errorbars are drawn at -row1 and +row2 relative to the data.
However, if you pass a N×2 shaped array, the data still plots - but incorrectly.
Here's an example:
x = np.arange(5) + .5
y = np.array([1,2,1.5, 2.5, 2.])
yerr = np.array([
(.1,.2),
(.1,.2),
(.1,.2),
(.1,.2),
(.1,.2)
])
# correct behavior
plt.figure()
err = yerr.T
print(np.shape(err)) # (2, 5)
plt.errorbar(x, y, err)
plt.xlim(0, 5)
# incorrect behavior
plt.figure()
err = yerr
print(np.shape(err))
plt.errorbar(x, y, err) (5, 2)
plt.xlim(0, 5)
And here are the two plots:
Metadata
Metadata
Assignees
Labels
No labels