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: Allow to register standalone figures with pyplot#29855

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

Draft
timhoffm wants to merge1 commit intomatplotlib:main
base:main
Choose a base branch
Loading
fromtimhoffm:pyplot-register-figure

Conversation

timhoffm
Copy link
Member

@timhoffmtimhoffm commentedApr 1, 2025
edited
Loading

It may be fundamentally nice not to have to create the figure though pyplot to be able to use it in pyplot afterwards. You can now do

from matplotlib.figure import Figureimport matplotlib.pyplot as pltfig = Figure()fig.subplots().plot([1, 3, 2])plt.figure(fig)  # fig is now tracked in pyplotplt.show()

This also opens up the possibility to more dynamically track and untrack figures in pyplot, which opens up the road to optimized figure tracking in pyplot (#29849)

Anybody, feel free to play around with this and try to break it.

anntzer, story645, and rcomer reacted with heart emoji
It may be fundamentally nice not to have to create the figurethough pyplot to be able to use it in pyplot afterwards. You can now do```from matplotlib.figure import Figureimport matplotlib.pyplot as pltfig = Figure()fig.subplots().plot([1, 3, 2])plt.figure(fig)  # fig is now tracked in pyplotplt.show()```This also opens up the possibility to more dynamically trackand untrack figures in pyplot, which opens up the road tooptimized figure tracking in pyplot (matplotlib#29849)
@timhoffmtimhoffmforce-pushed thepyplot-register-figure branch from56f4ee1 tof97c262CompareApril 1, 2025 22:19
@rcomer
Copy link
Member

rcomer commentedApr 2, 2025
edited
Loading

I was hoping I could modify the figure and show again, but that does not seem to be the case

importmatplotlib.pyplotaspltfrommatplotlib.figureimportFigurefig=Figure()ax=fig.subplots()ax.plot([0,2])plt.figure(fig)plt.show()ax.set_title('A cool line')plt.figure(fig)plt.show()

No title is shown 😕

timhoffm reacted with eyes emoji

@timhoffmtimhoffm marked this pull request as draftApril 2, 2025 11:34
@anntzer
Copy link
Contributor

This would also close#19956.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@timhoffm@rcomer@anntzer

[8]ページ先頭

©2009-2025 Movatter.jp