Skip to content

Plotting series (columns) fails #224

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

Closed
takluyver opened this issue Oct 12, 2011 · 6 comments
Closed

Plotting series (columns) fails #224

takluyver opened this issue Oct 12, 2011 · 6 comments
Labels
Milestone

Comments

@takluyver
Copy link
Contributor

Calling plot from matplotlib with series (e.g. columns of a DataFrame) fails, because it tries to add an axis to the series objects. A traceback can be found here: https://gist.github.com/1281034 .

One way to solve this could be, if we try to index a series to multiple dimensions, simply return a plain numpy array of the data. Or maybe it makes more sense to make changes on the matplotlib side?

Series.plot() and DataFrame.plot() are designed to plot columns against the index, but don't appear to help with plotting one column against another.

@wesm
Copy link
Member

wesm commented Oct 12, 2011

I was aware of this issue but wasn't sure what to do about it. The preferred way of doing plot(soy_w['Depth'])) is soy_w['Depth']).plot(). I honestly think matplotlib should be sneaking in an np.asarray in there somewhere.

When you say "plot one versus the other" you mean a scatter plot?

@takluyver
Copy link
Contributor Author

Yes, I am thinking of scatter plots - they're the commonest type of plot in my field. The plot(soy_w['Depth']) was just a minimal example to show the bug - I was actually trying to do plot(soy_w['Depth'], soy_w['OtherColumn']).

Would it make sesnse to fall back to an array if we try to index to additional axes? The key is mpl calling y = y[:,np.newaxis]. Even if this is just a temporary measure while we get matplotlib to handle pandas structures better, I think it's pretty critical to work well with matplotlib.

@wesm
Copy link
Member

wesm commented Oct 12, 2011

I definitely agree that good integration with mpl is important-- where is the right place to report these issues? I guess it's sort of my own fault for breaking the ndarray interface in getitem, but I think it's a worthwhile tradeoff. I think we can put in a hack without breaking any unit tests, will take a look later today (after I get my PyCon proposals done)

@takluyver
Copy link
Contributor Author

Thanks - I look forward to testing it (as you've probably guessed, I'm
having a go with pandas in my normal workflow, where I'd previously been
using tabular).

@wesm
Copy link
Member

wesm commented Oct 12, 2011

try it out and let me know if things work like they should now

@takluyver
Copy link
Contributor Author

I can confirm that's doing the trick. Thanks, Wes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants