-
-
Notifications
You must be signed in to change notification settings - Fork 8.4k
plt.bar() fails on 2D arrays with singleton dimensions. error message is unhelpful. #10733
Copy link
Copy link
Closed as not planned
Closed as not planned
Copy link
Labels
API: argument checkingValidation of acceptable argument valuesValidation of acceptable argument valuesAPI: consistencyConsistency of the matplotlib API, including naming, behavior, defaults, …Consistency of the matplotlib API, including naming, behavior, defaults, …status: closed as inactiveIssues closed by the "Stale" Github Action. Please comment on any you think should still be open.Issues closed by the "Stale" Github Action. Please comment on any you think should still be open.status: inactiveMarked by the “Stale” Github ActionMarked by the “Stale” Github Action
Milestone
Metadata
Metadata
Assignees
Labels
API: argument checkingValidation of acceptable argument valuesValidation of acceptable argument valuesAPI: consistencyConsistency of the matplotlib API, including naming, behavior, defaults, …Consistency of the matplotlib API, including naming, behavior, defaults, …status: closed as inactiveIssues closed by the "Stale" Github Action. Please comment on any you think should still be open.Issues closed by the "Stale" Github Action. Please comment on any you think should still be open.status: inactiveMarked by the “Stale” Github ActionMarked by the “Stale” Github Action
Type
Fields
Give feedbackNo fields configured for issues without a type.
Bug report
Bug summary
plt.bar() only accept 1D arrays, and does not accept 2D arrays with a dimension that has length 1. E.g., does not accept arrays with shape (3,1). Unfortunately, the traceback is unhelpful.
Code for reproduction
Actual outcome
Expected outcome
plt.bar() should be able to figure out that a 1D vector and a 2D array with a singleton dimension are equivalent. This can be done by applying squeeze if necessary. In any case if plt.bar() is going to fail unintuitively on this, it should test to see if the input is a 2D array, and provide an informative error message.
Matplotlib version
print(matplotlib.get_backend())):This code works with matplotlib version 1.4.2 and does not work with 2.1.1. Other pyplot functions do not exhibit this behavior. E.g., plt.plot(np.zeros((2,1)),np.zeros((2,1))) works fine.