Fix asymmetric error bars for series (closes #9536)
State: closed

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.


Labels:
name: Bug
name: Visualization
description: plotting

Comments:
- does this have a related issue?
- needs a whatsnew note. is this an APi change?
- does the do-string need updating?
- needs some tests

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.
I did add some more documentation on the docstring and the undocumented feature of providing a single number to use for every error bar.
I also did add a test.

[0] http://pandas.pydata.org/pandas-docs/stable/visualization.html#visualization-errorbars
[1] http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.errorbar

whatsnew note in `doc/source/whatsnew/v0.18.0.txt` under API changes

@kleingeist can you update

@jreback sorry, i had a lot to do last week and couldn't look into it.
i tried to adapt the changes to your requests and did add test and a note in the whatsnew under "Api -> Other enhancements". I hope this is the right place?

Regarding your [line comment](https://github.com/pydata/pandas/pull/12046#discussion-diff-50161835R1472) 

> I would like to see a more general soln here, rather than specific ndim checking.

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. 
The more general solution is available in the form of Mx2xN arrays which can be already used for plotting asymmetric error bars for M multiple values of dataframes. 
For Series it is already possible to use this general solution by providing a 1x2xN shaped array for asymmetric error bars. 
But i would argue this is counterintuitive as the [matplotlib api](http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.errorbar) uses the 2xN format and i, as well as others #9536, http://stackoverflow.com/q/26793758/4262879 did expect that the pandas API would work the same. 

can you rebase/update

@jreback ✓

@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.