-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
Plotting secondary axis #9302
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
Hmm, those examples are plotting Series. Your code works if you do |
Related issue: #8776 |
Thank you, @TomAugspurger. I also think it should work for dataframes. The documentation makes no distinction, and why to limit the plot functionality anyway... |
I guess the real solution is to catch the In [33]: ax = x.plot()
In [34]: y.plot(secondary_y=True,style='g:', ax=ax)
Out[34]: <matplotlib.axes._subplots.AxesSubplot at 0x10086630> This will work for multiple columns. If you don't mind, I'm going to close this issue, since it's going to be "fixed" by however we handle #8776. If you haven't looked at that issue, it's about how Series.plot() plots on the currently active axis, while DataFrame.plot() plots on a new one. |
@TomAugspurger, indeed, that's a nice workaround. I think the documentation could make that clear. The example presented only works for series, and the documentation does not specifically exclude dataframes. Thanks for the hint!! |
This could be either a bug, or an error in the documentation, or just my fault (hopefully the third reason).
Pandas 0.15.2 documentation explains how to create one plot with two axes (http://pandas.pydata.org/pandas-docs/dev/visualization.html?highlight=visualization#plotting-on-a-secondary-y-axis). For example:
The problem is, two plots are generated, rather than only one with two axes.
This alternative would work:
Question: Does the example in the documentation actually generate a plot with 2 axes? What I get is two separate plots. This seems to be a bug. If this is not a bug, then I would suggest the example in the documentation is modified to explain the second alternative.
The text was updated successfully, but these errors were encountered: