-
-
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
Conversation
|
Yes, as mentioned in the commit subject and the title this is associated to issue #9536 . I am not sure what you mean by "needs a whatsnew note" and undecided if i would call it an API change. The current doc [0] states "Asymmetrical error bars are also supported, however raw error values must be provided in this case. For a M length Series, a Mx2 array should be provided indicating lower and upper (or left and right) errors." which is, as noted in #9536 not working. Still, after this commit the documented syntax is changed from 2xM to Mx2 as is the format matplotlib expects asymmetrical error bars. So probably it makes sense to document it as an API change. [0] http://pandas.pydata.org/pandas-docs/stable/visualization.html#visualization-errorbars |
@@ -1419,10 +1419,16 @@ 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 comment
The 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.
whatsnew note in |
@kleingeist can you update |
@jreback sorry, i had a lot to do last week and couldn't look into it. Regarding your line comment
i have no idea how to do that. The fix is for one specific case: Only one Series to plot, with error bars given as raw values in an array of shape 2xN. I don't know to come up for a more general solution for this special case. |
@@ -152,6 +152,7 @@ Other enhancements | |||
- ``Series`` gained an ``is_unique`` attribute (:issue:`11946`) | |||
- ``DataFrame.quantile`` and ``Series.quantile`` now accept ``interpolation`` keyword (:issue:`10174`). | |||
- ``DataFrame.select_dtypes`` now allows the ``np.float16`` typecode (:issue:`11990`) | |||
- ``Series.plot`` allows now asymmetric error bars in the shape of 2xN array (:issue:`9536`) |
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.
move to 0.18.1
can you rebase/update |
@jreback ✓ |
This fix is for handling asymmetric error bars for series. It adapts to the syntax for http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.errorbar where a sequence of shape 2xN is expected in case of asymmetric error bars. If a single series is to be plotted and the error sequence is of shape 2xN it will be used as asymmetric error bars. Previously a 2xN error sequence was assumed to be 2 symmetric error sequences for 2 series. Thus in the end only the first error sequence was used. This commit improves the docstring of the `_parse_errorbars` method as well as the general pandas doc on error bars.
@@ -60,12 +60,13 @@ Other Enhancements | |||
- ``pd.read_msgpack()`` now always gives writeable ndarrays even when compression is used (:issue:`12359`). | |||
- ``Index.take`` now handles ``allow_fill`` and ``fill_value`` consistently (:issue:`12631`) | |||
|
|||
.. ipython:: python | |||
.. ipython:: python |
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.
@TomAugspurger i thought the .rst format would work like markdown, where i would have had to indent the code block if i would like it to be a child of a list-item. The newly indented code example is associated with the list item above, and since i wanted to add an item to the same list i indented the code block as i would have in markdown. I would really like to give up this PullRequest, as i thought i'd submit a short patch for an issue i encountered, but don't want to study the documentation of .rst files. Please feel free to fork the branch i started and adapt everything to your project guidelines / doc formats. Or drop the PR at all. I am fine with the workaround i found while debugging the error (adding another pair of parenthesis/ dimension to the 2xN asymmetric error bars list. |
closing as stale. but please reopen if you'd like to continue work. |
closes #9536
This fix is for handling asymmetric error bars for series.
It adapts to the syntax for
http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.errorbar
where a sequence of shape 2xN is expected in case of asymmetric error bars.
If a single series is to be plotted and the error sequence is of shape 2xN
it will be used as asymmetric error bars.
Previously a 2xN error sequence was assumed to be 2 symmetric error sequences
for 2 series. Thus in the end only the first error sequence was used.