-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
VIS: errorbar plotting #3796
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
Comments
It would be also great if something like this could work: df = pd.DataFrame({'row': list('abc' * 6),
'col': list('xxxxxxyyyyyyzzzzzz'),
'value': np.random.randn(18)+5})
mean = df.pivot_table(values='value', rows='row',
cols='col', aggfunc='mean')
err = df.pivot_table(values='value', rows='row',
cols='col', aggfunc='std')
mean.plot(kind='bar', yerr=err) Or any variation on the subject... |
I've been thinking a little about this API. It's a bit annoying because there umpteen parameters to @alefnula Your input on the API is most welcome. |
On second thought, the most obvious of having |
I'm not fully mastering the forking, branching, pull requesting process yet, so I try to contribute in this rather primitive way... The example of alefnula works perfect if one includes the following few lines at line 1488 of pandas.tools.plotting (i.e. inside the for loop of the
With those lines added, also this matplotlib gallery example becomes straightforward:
|
The solution of kdebrab is definitely the right way to go. However, by default matplotlib uses the same color for the errorbars if no error_kw is provided, which makes it impossible to see. I would suggest using a different default for the error bar colors. |
I have tried this too and could not get this working. |
I've made some headway on implementing this feature (using a lot of the nice suggestions in this thread). Right now my changes allow for errorbars on Line and Bar plots given a list/tuple/ndarray/Series of error values, a DataFrame of label-matched errors, or a column name. There are a couple of things I'm struggling with in terms of code neatness at this point. Log scale on line plots: the way this currently works is that depending on the values of logx/y keyword arguments, a specific matplotlib function is used (plot, semilogx, semilogy, or loglog). However, the simplest way to get error bars is with the matplotlib's errorbars, which can handle log scales via interacting with the axis directly:
I think a clean (but less conservative) way to get around this is to rewrite the line plot code to use matplotlib's plot and handle log axes with ax.set_xscale and ax.set_yscale, which as far as I can tell is what semilogx/y are doing under the hood. Any thoughts? I'll also give it a shot, maybe it's not going to be disruptive as I suspect. |
You can give it a shot. You'll need to be careful if you're changing things with the |
It's not directly tested. It's only tested through the user-facing API. Best, On Mon, Nov 25, 2013 at 9:08 AM, Tom Augspurger [email protected]:
|
I'm new to contributing, so I'd welcome any advice on how to make sure this is working properly. I've written some of my own tests, which are basically just running as many different combinations of plot arguments as I can think of. It survives those. Is there anything else I should try? |
Have you pushed your code to a branch yet? Try that and then we can look at it. Here's some notes on contributing, just post if you get stuck somewhere. |
Thanks for the link! I'll try to get up to speed. In the meantime, I've pushed the changes to my github account... https://github.com/gibbonorbiter/pandas. |
quoting @jreback
maybe
s = Series
s.plot(error_bar = [-1,1])
equiv to:
bottom seems the right way to do this....
The text was updated successfully, but these errors were encountered: