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

Improve docs regarding plt.close().#29839

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

Merged
timhoffm merged 1 commit intomatplotlib:mainfromanntzer:close
Apr 1, 2025
Merged

Conversation

anntzer
Copy link
Contributor

See#29782 (comment)

PR summary

PR checklist

Comment on lines 1190 to 1192
pyplot maintains a reference to figures created with `figure()` until
`close()` is called on them. Closing figures is thus necessary to prevent
running out of memory (see also :rc:`figure.max_open_warning`).
Copy link
Member

Choose a reason for hiding this comment

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

Can we get this more in the direction thatclose() is the explicit way to deregister a figure from pyplot? I want to prevent the implication that every figure() must be paired with close(). Closing a figure window that was created using show() also deregisters the figure from pyplot and hence close() is not needed in that usage scenario.

Something like

pyplot maintains a reference to figures created withfigure(). When work on the figure is completed, it should be closed, i.e. deregistered from pyplot, to free its memory (see also :rc:figure.max_open_warning).
Closing a figure window created byshow() automatically deregisters the figure. For all other use cases, most prominentlysavefig() withoutshow(), the figure must be deregistered explicitly usingclose().

tacaswell reacted with thumbs up emoji
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

sure, done

@timhoffm
Copy link
Member

timhoffm commentedApr 1, 2025
edited
Loading

Do we have an explicit documentation on the lifecycle of figures with pyplot (I'm not aware of that). If so, we could link there. If not, that's for another time/PR.

Anybody can merge after CI has run.

@timhoffmtimhoffm added this to thev3.10.2 milestoneApr 1, 2025
@timhoffmtimhoffm merged commit90385b4 intomatplotlib:mainApr 1, 2025
41 checks passed
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull requestApr 1, 2025
@anntzeranntzer deleted the close branchApril 1, 2025 11:49
timhoffm added a commit that referenced this pull requestApr 1, 2025
…839-on-v3.10.xBackport PR#29839 on branch v3.10.x (Improve docs regarding plt.close().)
@ksundenksunden mentioned this pull requestMay 9, 2025
5 tasks
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@dstansbydstansbydstansby left review comments

@jklymakjklymakjklymak approved these changes

@timhoffmtimhoffmtimhoffm approved these changes

Assignees
No one assigned
Labels
Documentation: user guidefiles in galleries/users_explain or doc/usersDocumentationtopic: pyplot API
Projects
None yet
Milestone
v3.10.3
Development

Successfully merging this pull request may close these issues.

4 participants
@anntzer@timhoffm@jklymak@dstansby

[8]ページ先頭

©2009-2025 Movatter.jp