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

matplotlib-1.2.0: regression in histogram with barstacked drawing? #1679

Closed
mmokrejs opened this issue Jan 17, 2013 · 9 comments
Closed

matplotlib-1.2.0: regression in histogram with barstacked drawing? #1679

mmokrejs opened this issue Jan 17, 2013 · 9 comments

Comments

@mmokrejs
Copy link

To: Matplotlib-users@lists.sourceforge.net
Message-ID: 50DF638E.80904@fold.natur.cuni.cz

Hi,
I recently updated to matplotlib-1.2.0 from 1.1.1 and my figures have rotated
order of color bars stacked upon each other. Here is a small testcase I sketched
now and two generated png files are attached, generated by the two different
matplotlib versions. The colornames are just bad in the legend, just to show that
the order of input data is same in both cases.

I would be grateful for any comments on this.
Thank you,
Martin

! /usr/bin/python

import pylab

F = pylab.gcf()

F.set_size_inches(11.2, 8.4)

_e = [[100, 100, 100, 100, 200, 320, 450, 80, 20, 600, 310, 800], [20, 23, 50, 11, 100, 420], [120, 120, 120, 140, 140, 150, 180], [60, 60, 60, 60, 300, 300, 5, 5, 5, 5, 10, 300], [555, 555, 555, 30, 30, 30, 30, 30, 100, 100, 100, 100, 30, 30], [30, 30, 30, 30, 400, 400, 400, 400, 400, 400, 400, 400]]
_ee = [(0.5759849696758961, 1.0, 0.0), (0.0, 1.0, 0.350624650815206), (0.0, 1.0, 0.6549834156005998), (0.0, 0.6569064625276622, 1.0), (0.28302699607823545, 0.0, 1.0), (0.6849123462299822, 0.0, 1.0)]
_eee = ['green', 'orange', ' yellow', 'magenta', 'black']

pylab.hist(_e, bins=10, histtype='barstacked', align='mid', color=_ee, log=False, label=_eee)

pylab.legend(loc='upper right', bbox_to_anchor = (1.0, 1.0), ncol=1)

F.savefig("hist_barstacked_bug.png", dpi=100)

@mmokrejs
Copy link
Author

Uploading hist_barstacked_bug__mpl-1.1.1.png . . .
Uploading hist_barstacked_bug__mpl-1.2.0.png . . .

@dmcdougall
Copy link
Member

v1.1.1:

hist_barstacked_bug__mpl-1 1 1

v1.2.0

hist_barstacked_bug__mpl-1 2 0

@mdboom
Copy link
Member

mdboom commented Jan 25, 2013

git bisect tells me the culprit is 7ba1743, but not sure exactly what the fix is yet.

@neggert
Copy link
Contributor

neggert commented Jan 25, 2013

I suspect you're correct. I'll take a look at it this weekend

@mmokrejs
Copy link
Author

Michael Droettboom wrote:

git bisect tells me the culprit is 7ba1743 7ba1743, but not sure exactly what the fix is yet.

Hi,
thanks for your work on this. BTW, I also notice that also a barstacked chart with log Y-axis
is also affected. Probably same underlying issue.
Martin

@neggert
Copy link
Contributor

neggert commented Jan 26, 2013

Alright, I think I remember now what I did. Since the stacked histogram is done by putting later histograms over the top of previous one, the upper-most one needed to be plotted first.

This approach of layering the patches seems to be causing other problems as well (#1631), so I may need to revisit how this is implemented. I seem to remember having problems with it when using fill_between, as suggested there. I'll take another stab at it and if I get stuck I'll submit the PR so others can take a look.

@dmcdougall
Copy link
Member

@neggert I think histograms can take a bottom= kwarg. Can you stack them that way instead?

@dmcdougall
Copy link
Member

@neggert I think histograms can take a bottom= kwarg. Can you stack them that way instead?

Scratch that. I think I was thinking of Axes.bar().

@mdboom
Copy link
Member

mdboom commented Mar 1, 2013

Closing since the relevant pull requests have been merged. Thanks!

@mdboom mdboom closed this as completed Mar 1, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants