Skip to content

Colors drawn outside axis for hist2d #7350

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
dfreese opened this issue Oct 25, 2016 · 5 comments
Closed

Colors drawn outside axis for hist2d #7350

dfreese opened this issue Oct 25, 2016 · 5 comments
Milestone

Comments

@dfreese
Copy link

dfreese commented Oct 25, 2016

A bit of a nitpick, but when working with hist2d in matplotlib 2.0.0b3 installed using pip on OS X 10.9.5, I see a problem with the colors being drawn outside the axis ever so slightly at the top and right of the figure. I generated the attached example using this code:

import matplotlib
print matplotlib.__version__
import matplotlib.pyplot as plt

measured = np.random.rand(4)

x_pos = np.array((0., 0, 1, 1))
y_pos = np.array((0., 1, 0, 1))

x_pos_unique = np.unique(x_pos)
y_pos_unique = np.unique(y_pos)

x_bins = np.unique(np.hstack((x_pos_unique - 0.5, x_pos_unique + 0.5)))
y_bins = np.unique(np.hstack((y_pos_unique - 0.5, y_pos_unique + 0.5)))

plt.figure()
plt.hist2d(x_pos, y_pos, weights=measured, bins=(x_bins, y_bins))
plt.colorbar()
plt.savefig('overfill_example.pdf')
plt.show()

overfill_example.pdf

overfill_example_zoom

@tacaswell tacaswell added this to the 2.0 (style change major release) milestone Oct 25, 2016
@tacaswell
Copy link
Member

This might be related to #6773 / #6776

@QuLogic
Copy link
Member

QuLogic commented Nov 16, 2016

Those tickets are for imshow while hist2d uses pcolorfast, and I can reproduce this all the way back to 1.4.3.

@QuLogic
Copy link
Member

QuLogic commented Nov 16, 2016

OK, so in this case, it seems like pcolorfast will end up using a mimage.AxesImage, but the fact that it's not new might still point to a different issue.

@tacaswell tacaswell modified the milestones: 2.0.1 (next bug fix release), 2.0 (style change major release) Nov 16, 2016
@tacaswell
Copy link
Member

moved to v2.0.1 as this is not a 2.0 induced bug.

@QuLogic
Copy link
Member

QuLogic commented Nov 16, 2016

On further inspection, I think it may have been made worse in the same way that #6773 was made worse.

QuLogic added a commit to QuLogic/matplotlib that referenced this issue Nov 16, 2016
I don't understand why there's a + 1 here, but it rounds up to the
next-next pixel instead of the next pixel. This makes images extend past
the end of the frame.

Fixes matplotlib#6773.
Fixes matplotlib#7350.
@QuLogic QuLogic modified the milestones: 2.0 (style change major release), 2.0.1 (next bug fix release) Dec 7, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants