FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

MNT: Warn if fixed aspect overwrites explicitly set data limits by timhoffm · Pull Request #28683 · matplotlib/matplotlib · GitHub

MNT: Warn if fixed aspect overwrites explicitly set data limits - #28683

Merged
ksunden merged 1 commit into
matplotlib:mainfrom
timhoffm:datalim
Sep 26, 2024
Merged

ksunden merged 1 commit into
matplotlib:mainfrom
timhoffm:datalim

Conversation

timhoffm commented Aug 8, 2024

Copy link
Copy Markdown
Member

Closes #28673.

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.

timhoffm Aug 8, 2024 •
edited
Loading

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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.

timhoffm added this to the v3.9.2 milestone Aug 8, 2024

Copy link
Copy Markdown
Member

I do not think users will see this by default (or I may be confused about logging)?

Copy link
Copy Markdown
Member

I also am not sure that we want to backport this. It is a minor change to long standing behavior.

timhoffm commented Aug 8, 2024

Copy link
Copy Markdown
Member Author

I do not think users will see this by default (or I may be confused about logging)?

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 warnings.warn. From [logging tutorial(https://docs.python.org/3/howto/logging.html#logging-basic-tutorial)

Use warnings.warn() in library code if the issue is avoidable and the client application should be modified to eliminate the warning

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.

I also am not sure that we want to backport this.

No strong opinion. I've mainly target 3.9.x to get the doc hint in. But we can also target 3.10.

QuLogic modified the milestones: v3.9.2, v3.9.3 Aug 12, 2024
timhoffm modified the milestones: v3.9.3, v3.10.0 Sep 16, 2024

ksunden left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Approved during discussion in community call

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: set_xlim, set_xbounds being ignored when set_aspect('equal', 'datalim') being used

5 participants


Back | FazBrowse Home | New Git URL