-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Only change axes aspect in imshow if image transform is/contains transData #26122
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
Conversation
lib/matplotlib/axes/_axes.py
Outdated
@@ -5585,6 +5585,11 @@ def imshow(self, X, cmap=None, norm=None, *, aspect=None, | |||
that the data fit in the Axes. In general, this will result in | |||
non-square pixels. | |||
|
|||
This parameter is ignored if the image uses a transform that does |
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.
Is this really what we want? If you do this then aspect=2
no longer will work. This seems like such an edge case, I'd rather just force users to pass aspect='auto'
, eg keep the current state.
or im.get_transform().contains_branch(self.transData)): | ||
if aspect is None: | ||
aspect = mpl.rcParams['image.aspect'] | ||
self.set_aspect(aspect) |
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 agree ignoring explicit user input is bad, I think we should only skip doing something with aspect if aspect
is None.
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 could also see a case for raising if both transform
and aspect
are passed...
… transData. If the image transform does not contain transData then setting the axes aspect to 1 will typically not help to make image pixel squares anyways.
Fair enough, I only changed the behavior of |
Failing tests are an upload to codecov error. I'll merge as I feel @tacaswell and I had the same point and this fixes it. |
If the image transform does not contain transData then setting the axes aspect to 1 will typically not help to make image pixel squares anyways.
Closes #14118.
PR summary
PR checklist