-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
MNT: Warn if fixed aspect overwrites explicitly set data limits #28683
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
@@ -1705,7 +1705,8 @@ def set_adjustable(self, adjustable, share=False): | |||
---------- | |||
adjustable : {'box', 'datalim'} | |||
If 'box', change the physical dimensions of the Axes. | |||
If 'datalim', change the ``x`` or ``y`` data limits. | |||
If 'datalim', change the ``x`` or ``y`` data limits. This | |||
may ignore explicitly defined axis limits. |
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.
Note: I've intentionally written may because in the current implementation one can have scenarios where the limits are respected. For example
fig, ax = plt.subplots()
ax.set_aspect('equal', 'datalim')
ax.plot([0, 1], [0, 2])
ax.set_ylim(-5, 5)
Just looking at the data, the y-range is larger, so to get all data shown on equal aspect, x has to be increased. Thus, new xlims are calculated, but taking the ylim (not the ydata) into account. Whether this behavior of sometimes taking limits into account and sometimes not is desireable, is a separate question that I don't want to discuss. The doc now only states that it may (or may not) happen. Note however, that the added runtime warning is precise: It will be emitted exactly if we change previously fixed limits.
I do not think users will see this by default (or I may be confused about logging)? |
I also am not sure that we want to backport this. It is a minor change to long standing behavior. |
I checked in my dev environment (don't think I've configured something special there): python shell, ipython shell, python script all show this. Alternative would be
That's the question: Do we see this as a misuse and want users to change their code? Or do we only want to inform? Given the somewhat peculiar behavior that this warning depends on the set limits and used data, I've been hesitant to request a code change, even if that means some logging configuration may not show the message.
No strong opinion. I've mainly target 3.9.x to get the doc hint in. But we can also target 3.10. |
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.
Approved during discussion in community call
Closes #28673.