Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

ENH: ax.add_collection(..., autolim=True) updates view limits#29958

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
timhoffm wants to merge1 commit intomatplotlib:main
base:main
Choose a base branch
Loading
fromtimhoffm:add_collection_viewlims

Conversation

timhoffm
Copy link
Member

@timhoffmtimhoffm commentedApr 22, 2025
edited
Loading

This makes explicit calls toautoscale_view() or_request_autoscale_view() unnecessary.

3D Axes have a specialauto_scale_xyz(), also there's a mixture ofadd_collection() andadd_collection3d(). This needs separate sorting . I've added a private valueautolim="_datalim_only" to keep the behavior for 3D Axes unchanged for now. That will be resolved by a follow-up PR. I believe it's getting too complicated if we fold this into the 2D change.

Also for follow-ups:

  • There are some usages in tests and examples, where set_xlim/set_ylim pins the limits, which seems to be used as an alternative toautoscale_view it may be that we can now remove the explicit limits for some cases since the autoscaled view is good enough.
  • We have a number of places that explicitly useautolim=True, which is the default. We may remove these, but it seems they are sometimes used as explicit communication of intent. Also the comment in
    # explicitly, leave out the *autolim* keyword argument (or set it to False),
    suggests thatautolim=False may have been the default a long time ago. - This should be investigated (Edit: Indeed, the default was changed in 2007 by0df13d7).

Closes#29957.

This makes explicit calls to `autoscale_view()` or`_request_autoscale_view()` unnecessary.3D Axes have a special `auto_scale_xyz()`, also there's a mixture of`add_collection()` and `add_collection3d()`. This needs separate sorting. I've added a private value `autolim="_datalim_only"` to keep thebehavior for 3D Axes unchanged for now. That will be resolved by afollow-up PR. I believe it's getting too complicated if we fold thisinto the 2D change.
@timhoffmtimhoffmforce-pushed theadd_collection_viewlims branch 2 times, most recently frome5b0541 toe7b2708CompareApril 22, 2025 11:20
@@ -371,7 +371,7 @@ def __init__(
colors=[mpl.rcParams['axes.edgecolor']],
linewidths=[0.5 * mpl.rcParams['axes.linewidth']],
clip_on=False)
self.ax.add_collection(self.dividers)
self.ax.add_collection(self.dividers, autolim=False)
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

These are decorations on the colorbar and should not influence its limits.

@@ -805,7 +805,7 @@ def add_lines(self, *args, **kwargs):
xy = self.ax.transAxes.inverted().transform(inches.transform(xy))
col.set_clip_path(mpath.Path(xy, closed=True),
self.ax.transAxes)
self.ax.add_collection(col)
self.ax.add_collection(col, autolim=False)
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Here as well: These are decorations on the colorbar and should not influence its limits.

Comment on lines +166 to +168
# TODO: check whether the above explicit limit handling can be
# replaced by autolim=True
ax.add_collection(collection, autolim=False)
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Since there is an explicitupdate_datalim(); autoscale_view() above,autolim=True has no effect. Settingautolim=False for now to make that clear. We may whether the explicit handling can be removed in favor ofautolim=True, but I'll leave that for later.

@timhoffmtimhoffm marked this pull request as ready for reviewApril 22, 2025 11:44
@timhoffmtimhoffm added this to thev3.11.0 milestoneApr 22, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@dstansbydstansbydstansby left review comments

@scottshambaughscottshambaughscottshambaugh approved these changes

Assignees
No one assigned
Labels
Projects
None yet
Milestone
v3.11.0
Development

Successfully merging this pull request may close these issues.

[ENH]: add_collection(..., autolim=True) should update view limits as well
3 participants
@timhoffm@dstansby@scottshambaugh

[8]ページ先頭

©2009-2025 Movatter.jp