8000 errorbar incorrectly accepts and plots Nx2 shaped yerr · Issue #4984 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content
errorbar incorrectly accepts and plots Nx2 shaped yerr #4984
Closed
@wackywendell

Description

@wackywendell

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:

errorbar-correct
errorbar-incorrect

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0