-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Range bug fix for pcolor and pcolormesh #1314
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 all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7364,6 +7364,20 @@ def pcolor(self, *args, **kwargs): | |
|
||
x = X.compressed() | ||
y = Y.compressed() | ||
|
||
# Transform from native to data coordinates? | ||
t = collection._transform | ||
if (not isinstance(t, mtransforms.Transform) | ||
and hasattr(t, '_as_mpl_transform')): | ||
t = t._as_mpl_transform(self.axes) | ||
|
||
if t and any(t.contains_branch_seperately(self.transData)): | ||
trans_to_data = t - self.transData | ||
pts = np.vstack([x, y]).T.astype(np.float) | ||
transformed_pts = trans_to_data.transform(pts) | ||
x = transformed_pts[..., 0] | ||
y = transformed_pts[..., 1] | ||
|
||
minx = np.amin(x) | ||
maxx = np.amax(x) | ||
miny = np.amin(y) | ||
|
@@ -7490,6 +7504,19 @@ def pcolormesh(self, *args, **kwargs): | |
collection.autoscale_None() | ||
|
||
self.grid(False) | ||
|
||
# Transform from native to data coordinates? | ||
t = collection._transform | ||
if (not isinstance(t, mtransforms.Transform) | ||
and hasattr(t, '_as_mpl_transform')): | ||
t = t._as_mpl_transform(self.axes) | ||
|
||
if t and any(t.contains_branch_seperately(self.transData)): | ||
trans_to_data = t - self.transData | ||
pts = np.vstack([X, Y]).T.astype(np.float) | ||
transformed_pts = trans_to_data.transform(pts) | ||
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. The only problem with this (and the fix that I implemented), is that the result of transform could be 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. @pelson Under what circumstances would this case occur? 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. Try uncommenting the
Changing the transform to fix inf points will solve the issue:
This means, if inf/nan is ignored at the level that this PR fixes, then we will get the "correct" limits. 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. Ah, by range you mean the x/y range, not the "z" range. 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. Actually, even with @bblay's fix, the data is still not put in the correct range... 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. Nevermind; I was being retarded. |
||
X = transformed_pts[..., 0] | ||
Y = transformed_pts[..., 1] | ||
|
||
minx = np.amin(X) | ||
maxx = np.amax(X) | ||
|
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.
Can this be None? In some other artists it can, but perhaps not here...
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.
I think the None case is handled by the next line, no?
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.
Agreed. The None case is handled in exactly the same way as it was previously.