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

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

@timhoffm timhoffm commented Aug 8, 2024

Copy link
Copy Markdown
Member

Closes #28673.

@timhoffm timhoffm Aug 8, 2024

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.

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 timhoffm added this to the v3.9.2 milestone Aug 8, 2024
@tacaswell

Copy link
Copy Markdown
Member

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

@tacaswell

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

timhoffm commented Aug 8, 2024

Copy link
Copy Markdown
Member Author

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

@ksunden 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.

Approved during discussion in community call

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