Skip to content

DOC: update outdated examples/api directory reference#31938

Open
vishrutakrishnamoorthy-ai wants to merge 2 commits into
matplotlib:mainfrom
vishrutakrishnamoorthy-ai:fix-docs-31935
Open

DOC: update outdated examples/api directory reference#31938
vishrutakrishnamoorthy-ai wants to merge 2 commits into
matplotlib:mainfrom
vishrutakrishnamoorthy-ai:fix-docs-31935

Conversation

@vishrutakrishnamoorthy-ai

Copy link
Copy Markdown

Fixes #31935

Replaced the outdated reference to the examples/api directory, which no longer exists, with a reference to the API interfaces documentation.

@github-actions

Copy link
Copy Markdown

Thank you for opening your first PR into Matplotlib!

If you have not heard from us in a week or so, please leave a new comment below and that should bring it to our attention. Most of our reviewers are volunteers and sometimes things fall through the cracks. We also ask that you please finish addressing any review comments on this PR and wait for it to be merged (or closed) before opening a new one, as it can be a valuable learning experience to go through the review process.

You can also join us on discourse chat for real-time discussion.

For details on testing, writing docs, and our review process, please see the developer guide.
Please let us know if (and how) you use AI, it will help us give you better feedback on your PR.

We strive to be a welcoming and open project. Please follow our Code of Conduct.

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

Thanks @vishrutakrishnamoorthy-ai I have one small suggestion and you will also need to fix the linting error.

The easiest way to address linting problems is to install the pre-commit hooks.
https://matplotlib.org/devdocs/devel/development_setup.html#install-pre-commit-hooks

Comment thread galleries/examples/user_interfaces/GALLERY_HEADER.rst Outdated
Comment thread galleries/examples/user_interfaces/GALLERY_HEADER.rst Outdated
Co-authored-by: Ruth Comer <10599679+rcomer@users.noreply.github.com>
@rcomer

rcomer commented Jul 1, 2026

Copy link
Copy Markdown
Member

Since it has been a week and the change is tiny, I took the liberty of pushing a commit with my suggestion and to fix the linting. Perhaps another maintainer can confirm this looks OK.

@timhoffm

timhoffm commented Jul 1, 2026

Copy link
Copy Markdown
Member

I think this doesn't quite cut it.

When embedding Matplotlib in a GUI, you must use the Matplotlib API
directly rather than the pyplot procedural interface. See
:ref:api_interfaces for an overview of Matplotlib's API interfaces.

The distinction in api_interfaces is between the "explicit Axes interface" and the "implicit pyplot interface". This primarily boils down to fig.some_func/ax.some_func vs plt.some_func. But what we need here ist the figure creation of bare Figure objects via fig = Figure() as opposed to managed Figures via plt.figure().

"the Matplotlib API" is too vague. Possibly the intention is something like

When embedding Matplotlib in a GUI, you must create standalone figure objects via fig = Figure() and not use pyplot-managed figures (plt.figure() or plt.subplots()).

The backgorund is that pyplot manages the window and eventloop, and that a GUI app wants to do this as well.

But there are also two funky examples (pyplot with GTK3/4), where the control is still left with pyplot, and we instead hack into the pyplot-managed window to extend it 🤯.

I see two options:

  1. Either do something like my above recommendation, knowing that it's a bit over-simplified.
  2. Or remove the block completely.

I'm leaning towards 2, since the gallery overview is not the place for coding specifics. Unforuntately we don't have a good place where the fundamental GUI pattern is explained. - There's more to it than just Figure(), it's also the Canvas and optionally Toolbars that need wiring up. It would be good to describe this as a tutorial at the example of one of the GUI frameworks. That should land either as first example in that section (maybe commenting on an existing example would be enough) or be a section in https://output.circle-artifacts.com/output/job/16c3ca48-942a-4d2e-9604-2d0be7802987/artifacts/0/doc/build/html/users/explain/figure/index.html.


Edit: Let's do it like this: Do 1. as an incremental improvement and create a follow-up issue for 2, which will remove the paragraph from the overview.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Doc]: examples/api directory?

3 participants