Skip to content
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

area plots are causing my unit tests to fail #9161

Closed
argriffing opened this issue Dec 28, 2014 · 9 comments · Fixed by #13680
Closed

area plots are causing my unit tests to fail #9161

argriffing opened this issue Dec 28, 2014 · 9 comments · Fixed by #13680
Labels

Comments

@argriffing
Copy link

I'm using the latest matplotlib and pandas. If you run the following code, do the legends look right to you? The unit tests don't like them.

df = DataFrame(
            np.random.rand(10, 3),
            index=list(string.ascii_letters[:10]))
df.plot(kind='area', subplots=True, sharex=True, legend=True)
@rockg
Copy link
Contributor

rockg commented Dec 28, 2014

What does the image look like? Here's what I get:

figure_1

@argriffing
Copy link
Author

@rockg Thanks for posting an image! That is indeed what the unit tests expect, but the legends are screwed up for me in the following way. Each of the three sub-plots has two elements in the legend instead of one -- they are weirdly duplicated, and I possibly blame my new development branch installation of matplotlib.

If your legend in the first of your three sub-plots looks like this

+--------+
|        |
| ---  0 |
|        |
+--------+

then the one I see looks like this:

+--------+
|        |
| ---  0 |
|        |
| XXX  0 |
|        |
+--------+

Similarly for the other two subplots. I detected this problem by failing the pandas unit-tests, and I've extracted from the failing unit tests this minimal (or at least smaller) example.

@tacaswell
Copy link
Contributor

My guess is matplotlib/matplotlib#3303 is the cause.

@argriffing
Copy link
Author

@tacaswell Just to be clear, you are guessing that matplotlib/matplotlib#3303 caused the regression, not that it fixes the regression?

@tacaswell
Copy link
Contributor

Correct, I suspect that pandas is working around the issue of poly collections not having a proper legend handler and now that it has one, you are getting double legend entries.

3303 is a major new feature 😄

[edited to fix word-salad]

@jreback
Copy link
Contributor

jreback commented Jan 2, 2015

ok, so this is a reverse-bug fix, e.g. when matplotlib 1.5 is out, pandas needs to compensate?

@jreback jreback added this to the 0.16.1 milestone Jan 2, 2015
@tacaswell
Copy link
Contributor

Yes, but I think it should (eventually) result in simplification of your code.

Can someone point me to where the relevant bit of code is and I can try to provide said compensation.

@jreback
Copy link
Contributor

jreback commented Jan 2, 2015

@TomAugspurger
cc @sinhrks

can you provide a link?

@sinhrks
Copy link
Member

sinhrks commented Jan 3, 2015

@tacaswell , @jreback
Here it is. Maybe AreaPlot._add_legend_handle can be removed after 1.5?
https://github.com/pydata/pandas/blob/master/pandas/tools/plotting.py#L1756

@jreback jreback modified the milestones: 0.16.1, 0.17.0 Apr 28, 2015
@jreback jreback modified the milestones: Next Major Release, 0.17.0 Aug 15, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants