-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
Fix asymmetric error bars for series (closes #9536) #12046
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1419,10 +1419,17 @@ def _parse_errorbars(self, label, err): | |
Error bars can be specified in several ways: | ||
Series: the user provides a pandas.Series object of the same | ||
length as the data | ||
ndarray: provides a np.ndarray of the same length as the data | ||
list_like (list/tuple/ndarray/iterator): either a list like of the | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if you are changing this, then pls provide tests for what you are adding. |
||
same length N as the data has to be provided | ||
or a list like of the shape Mx2xN for asymmetrical error | ||
bars when plotting a DataFrame of shape MxN | ||
or a list like of the shape 2xN for asymmetrical error bars | ||
when plotting a Series. | ||
DataFrame/dict: error values are paired with keys matching the | ||
key in the plotted DataFrame | ||
str: the name of the column within the plotted DataFrame | ||
numeric scalar: the error provided as a number is used for every | ||
data point | ||
''' | ||
|
||
if err is None: | ||
|
@@ -1458,22 +1465,33 @@ def match_labels(data, e): | |
|
||
elif com.is_list_like(err): | ||
if com.is_iterator(err): | ||
err = np.atleast_2d(list(err)) | ||
err = np.asanyarray(list(err)) | ||
else: | ||
# raw error values | ||
err = np.atleast_2d(err) | ||
err = np.asanyarray(err) | ||
|
||
err_shape = err.shape | ||
if self.nseries == 1 and err.ndim == 2 and len(err) == 2: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would like to see a more general soln here, rather than specific ndim checking. |
||
# asymmetrical errors bars for a series as a 2xN array | ||
err = np.expand_dims(err, 0) | ||
err_shape = err.shape | ||
|
||
# asymmetrical error bars | ||
if err.ndim == 3: | ||
if (err_shape[0] != self.nseries) or \ | ||
(err_shape[1] != 2) or \ | ||
(err_shape[2] != len(self.data)): | ||
if err_shape[2] != len(self.data): | ||
msg = "Asymmetrical error bars should be provided " + \ | ||
"with the shape (%u, 2, %u)" % \ | ||
(self.nseries, len(self.data)) | ||
"with the shape (2, %u)" % (len(self.data)) | ||
raise ValueError(msg) | ||
else: | ||
err = np.atleast_2d(err) | ||
err_shape = err.shape | ||
|
||
# asymmetrical error bars | ||
if err.ndim == 3: | ||
if (err_shape[0] != self.nseries) or \ | ||
(err_shape[1] != 2) or \ | ||
(err_shape[2] != len(self.data)): | ||
msg = "Asymmetrical error bars should be provided " + \ | ||
"with the shape (%u, 2, %u)" % \ | ||
(self.nseries, len(self.data)) | ||
raise ValueError(msg) | ||
|
||
# broadcast errors to each data series | ||
if len(err) == 1: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like these changes slipped in accidentally? Till line 67.