Skip to content

API: only shrink hist bars if not stacked - #6887

Merged
efiring merged 3 commits into
matplotlib:v2.xfrom
tacaswell:api_stacked_hist_width
Sep 6, 2016
Merged

efiring merged 3 commits into
matplotlib:v2.xfrom
tacaswell:api_stacked_hist_width

Conversation

@tacaswell

Copy link
Copy Markdown
Member

Partially addresses #6876

so

from matplotlib import pyplot as plt

x1 = [ 0.1, 0.2, 0.3, 0.5, 0.75, 1.1, 1.5, 1.9, 2.5, 2.9 ]
x2 = list(x1)
x2.extend([ 1.75, 1.8, 2.2, 2.4, 2.7, 2.8 ])

x1.extend([ -x for x in x1 ])
x2.extend([ -x for x in x2 ])

print("unstacked datasets, explicit bin sequence:")
plt.subplot(221)
plt.minorticks_on()
n, bins, patches = plt.hist([x1, x2], bins=[-3,-2,-1,0,1,2,3])
print("bins: ({}, {})".format(min(bins), max(bins)))
print("datalim: {}".format(plt.gca().dataLim))
print()

print("unstacked datasets, automatic bins:")
plt.subplot(222)
plt.minorticks_on()
n, bins, patches = plt.hist([x1, x2])
print("bins: ({}, {})".format(min(bins), max(bins)))
print("datalim: {}".format(plt.gca().dataLim))
print()

print("stacked datasets, explicit bin sequence:")
plt.subplot(223)
plt.minorticks_on()
n, bins, patches = plt.hist([x1,x2], bins=[-3,-2,-1,0,1,2,3], stacked=True)
print("bins: ({}, {})".format(min(bins), max(bins)))
print("datalim: {}".format(plt.gca().dataLim))
print()

print("stacked datasets, automatic bins:")
plt.subplot(224)
plt.minorticks_on()
n, bins, patches = plt.hist([x1,x2], stacked=True)
print("bins: ({}, {})".format(min(bins), max(bins)))
print("datalim: {}".format(plt.gca().dataLim))

@QuLogic

QuLogic commented Aug 3, 2016

Copy link
Copy Markdown
Member

Is it just me, or is the first bar a half-pixel off compared with the rest?

@tacaswell

Copy link
Copy Markdown
Member Author

@QuLogic it is not just you 😞

@tacaswell tacaswell added this to the 2.0.1 (next bug fix release) milestone Aug 28, 2016
@tacaswell
tacaswell force-pushed the api_stacked_hist_width branch from b5c7311 to 22a9f8f Compare August 28, 2016 16:54
@tacaswell tacaswell modified the milestones: 2.0 (style change major release), 2.0.1 (next bug fix release) Aug 30, 2016
@jenshnielsen

jenshnielsen commented Aug 30, 2016 •

Copy link
Copy Markdown
Member

The fix in 9a6ec8f should close also close #4212 and #4602 in addition to #6959

@jenshnielsen

Copy link
Copy Markdown
Member

Unfortunatly a lot of tests now need to be regenerated

In all cases new versions look more correct
@tacaswell tacaswell added the Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. label Sep 5, 2016
@efiring
efiring merged commit 3297e37 into matplotlib:v2.x Sep 6, 2016
@tacaswell
tacaswell deleted the api_stacked_hist_width branch September 6, 2016 00:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants