-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
hexbin log scale is broken in matplotlib 1.2.0 #1636
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
…euse the polygons can't work, so revert to the old method where each polygon is independent.
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6432,32 +6432,39 @@ def hexbin(self, x, y, C = None, gridsize = 100, bins = None, | |
offsets = offsets[good_idxs,:] | ||
accum = accum[good_idxs] | ||
|
||
if xscale=='log': | ||
offsets[:,0] = 10**(offsets[:,0]) | ||
xmin = 10**xmin | ||
xmax = 10**xmax | ||
self.set_xscale('log') | ||
if yscale=='log': | ||
offsets[:,1] = 10**(offsets[:,1]) | ||
ymin = 10**ymin | ||
ymax = 10**ymax | ||
self.set_yscale('log') | ||
|
||
polygon = np.zeros((6, 2), float) | ||
polygon[:,0] = sx * np.array([ 0.5, 0.5, 0.0, -0.5, -0.5, 0.0]) | ||
polygon[:,1] = sy * np.array([-0.5, 0.5, 1.0, 0.5, -0.5, -1.0]) / 3.0 | ||
|
||
if edgecolors=='none': | ||
edgecolors = 'face' | ||
|
||
collection = mcoll.PolyCollection( | ||
[polygon], | ||
edgecolors = edgecolors, | ||
linewidths = linewidths, | ||
offsets = offsets, | ||
transOffset = mtransforms.IdentityTransform(), | ||
offset_position = "data" | ||
) | ||
if xscale == 'log' or yscale == 'log': | ||
polygons = np.expand_dims(polygon, 0) + np.expand_dims(offsets, 1) | ||
if xscale == 'log': | ||
polygons[:,:,0] = 10.0 ** polygons[:,:,0] | ||
xmin = 10.0 ** xmin | ||
xmax = 10.0 ** xmax | ||
self.set_xscale(xscale) | ||
if yscale == 'log': | ||
polygons[:,:,1] = 10.0 ** polygons[:,:,1] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And here. |
||
ymin = 10.0 ** ymin | ||
ymax = 10.0 ** ymax | ||
self.set_yscale(yscale) | ||
collection = mcoll.PolyCollection( | ||
polygons, | ||
edgecolors = edgecolors, | ||
linewidths = linewidths, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. PEP8: Remove spaces around |
||
) | ||
else: | ||
collection = mcoll.PolyCollection( | ||
[polygon], | ||
edgecolors = edgecolors, | ||
linewidths = linewidths, | ||
offsets = offsets, | ||
transOffset = mtransforms.IdentityTransform(), | ||
offset_position = "data" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These look like kwargs. Could you remove the spaces surrounding |
||
) | ||
|
||
if isinstance(norm, mcolors.LogNorm): | ||
if (accum==0).any(): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -419,6 +419,20 @@ def test_hexbin_extent(): | |
|
||
ax.hexbin(x, y, extent=[.1, .3, .6, .7]) | ||
|
||
@image_comparison(baseline_images=['hexbin_log'], | ||
remove_text=True, | ||
extensions=['png']) | ||
def test_hexbin_log(): | ||
# Issue #1636 | ||
fig = plt.figure() | ||
|
||
n = 100000 | ||
x = np.random.standard_normal(n) | ||
y = 2.0 + 3.0 * x + 4.0 * np.random.standard_normal(n) | ||
y = np.power(2, y * 0.5) | ||
ax = fig.add_subplot(111) | ||
plt.hexbin(x,y,yscale='log') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. PEP8: Space after the commas. |
||
|
||
@cleanup | ||
def test_inverted_limits(): | ||
# Test gh:1553 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PEP8: Spaces after commas in indices.