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 new figure function in backends#18852

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
tacaswell wants to merge4 commits intomatplotlib:main
base:main
Choose a base branch
Loading
fromtacaswell:enh_new_figure

Conversation

tacaswell
Copy link
Member

PR Summary

Code arising out of a discussion on gitter, still needs a bunch of documentation and to sort out if we actually need to track the GUI windows (which I was asserting we did, but am no longer sure that is true).

PR Checklist

  • Has pytest style unit tests (andpytest passes).
  • IsFlake 8 compliant (runflake8 on changed files to check).
  • New features are documented, with examples if plot related.
  • Documentation is sphinx and numpydoc compliant (the docs shouldbuild without error).
  • Conforms to Matplotlib style conventions (installflake8-docstrings and runflake8 --docstring-convention=all).
  • New features have an entry indoc/users/next_whats_new/ (follow instructions in README.rst there).
  • API changes documented indoc/api/next_api_changes/ (follow instructions in README.rst there).

The docstring in ManagerBase claims that *num* can be str or int,however ever backend used int-specific formatting so this was notactually true.Fixed the backends rather than fixing the docstring (because settingthe window title on Manager init is useful and implicitly supportedthrough some special-casing in `plt.figure`).
The previous code only sets the title once, on refresh we would fallback to using the result of `fig.get_label()` if in is not the emptystring or f'Figure {num}'.
@tacaswelltacaswell added this to thev3.4.0 milestoneOct 31, 2020
@tacaswell
Copy link
MemberAuthor

I think things that could be added:

  • aclose method onFigure that forwards through to the manager likeshow does
  • aget_me_a_working_GUI_backend function that can be exposed (but not auto-called!) inmatplotlib.__init__
importmatplotlibasmplnew_figure=mpl.get_me_a_working_figure_factory()fig=new_figure('a label')ax_dict=fig.subplots_mosaic('AA\nBC')

@anntzer
Copy link
Contributor

See also#14024? I think in any case you need to changeshow to make such figuresshowable (unless I'm mistaken, in your PR, as it is, figures can't be shown).

@jklymak
Copy link
Member

importmatplotlibasmplnew_figure=mpl.get_me_a_working_figure_factory()fig=new_figure('a label')ax_dict=fig.subplots_mosaic('AA\nBC')

OK, but why can't this be spelled:

importmatplotlibasmplfig=mpl.figure()ax_dict=fig.subplots_mosaic('AA\nBC')

The user doesn't need to know that this factory is spooled up? I appreciate that makes some global state, but in__init__ that could just be:_figure_factory = None until the first call tompl.figure().

@tacaswell
Copy link
MemberAuthor

On the default branchfig.show() /fig.canvas.manager.show() works (but assumes you have done%gui qt or are managing the event loop on your own). There is currently a show method onFigure that just forwards tomanager.show(). I agree with@ImportanceOfBeingErnest 's comments in#14024 that we should not makeFigure.show run the event loop (to keep it closer to the semantics of a GUI framework).

linking to a conversation with@jklymak on gitter:https://gitter.im/matplotlib/matplotlib?at=5f9dc6c02a35440715f8e6a3

The lesson I have learned from working on Matplotlib is that global state is a giant headache as is doing GUI integration. I am very 👍 on us keeping the code to do that for the user, but I am not 100% sure we got everything right so am concerned about always calling that code for the user. I think it is important that we maintain a way for people who want to do their own thing to be sure that they will never have to deal with our (likely still buggy) attempts to "do the right thing" have a way to do that (by not importing the module where we act like an application rather than a library).

There definitely needs to be a way

@tacaswelltacaswell modified the milestones:v3.4.0,v3.5.0Jan 14, 2021
@tacaswell
Copy link
MemberAuthor

I don't have the bandwidth to push this across the line for 3.4.

@tacaswelltacaswell modified the milestones:v3.5.0,v3.6.0Aug 5, 2021
@tacaswell
Copy link
MemberAuthor

Pushing to 3.6

@timhoffmtimhoffm modified the milestones:v3.6.0,unassignedApr 30, 2022
@story645story645 modified the milestones:unassigned,needs sortingOct 6, 2022
@github-actions
Copy link

Since this Pull Request has not been updated in 60 days, it has been marked "inactive." This does not mean that it will be closed, though it may be moved to a "Draft" state. This helps maintainers prioritize their reviewing efforts. You can pick the PR back up anytime - please ping us if you need a review or guidance to move the PR forward! If you do not plan on continuing the work, please let us know so that we can either find someone to take the PR over, or close it.

@github-actionsgithub-actionsbot added the status: inactiveMarked by the “Stale” Github Action labelSep 4, 2023
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@anntzeranntzerAwaiting requested review from anntzer

@jklymakjklymakAwaiting requested review from jklymak

At least 1 approving review is required to merge this pull request.

Assignees
No one assigned
Labels
status: inactiveMarked by the “Stale” Github Actionstatus: needs rebase
Projects
None yet
Milestone
future releases
Development

Successfully merging this pull request may close these issues.

5 participants
@tacaswell@anntzer@jklymak@story645@timhoffm

[8]ページ先頭

©2009-2025 Movatter.jp