Skip to content

DOC: Add illustration to Figure.subplots_adjust #28844

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 22, 2024

Conversation

@timhoffm timhoffm added the Documentation: API files in lib/ and doc/api label Sep 19, 2024
@timhoffm timhoffm added this to the v3.10.0 milestone Sep 19, 2024
@jklymak
Copy link
Member

jklymak commented Sep 19, 2024

This is nice but same concern as previous one of these: most folks consume the api docs in IDEs and may be frustrated they cannot reach this. It'd be nice to work on a solution that allowed both the image and a link.

@timhoffm
Copy link
Member Author

Same answer: Link sounds nice but in a text-based renderer a usable realization is non-trivial. How should the link look like? Where should it point to? How would it be used?

The plots I add are supplementary illustrations. You can get all information from the text. It think we have to accept that some interfaces to the docstrings are just less capable and cannost show illustrations / have links. - We also live with the fact that code links like .Axes.set_xlim do not work in plain text.

@jklymak
Copy link
Member

jklymak commented Sep 19, 2024

It would take a new directive I suppose, but something like

.. example-plot:: https://matplotlib.org/stable/example_plots/example_subplots_adjust.png

which then either just display that in the rendered docs, or generated it from example_plots/example_subplots_adjust.py would be nicer. Of course the link being clickable would depend on the IDE.

.. image:: https://matplotlib.org/stable/example_plots/example_subplots_adjust.png

would be fine too if sphinx allowed the image directive to use an html. That has a bootstrapping problem in that the example plot would need to be on stable, whereas a new directive that created the file and put in the right spot would be better (the absolute path would be ignored in rendering).

@timhoffm
Copy link
Member Author

I would support such a directive. As you said, there are a number of aspects to work out. Related: It may also be an idea to have a link in every API doc something like: "Online version: https://matplotlib.org/stable/api/_as_gen/matplotlib.axes.Axes.margins.html" at the bottom. With that one gets access not only to the image but cross-references, related examples etc.

But all of this is off-topic. In this PR I'm just adding content, that is for now helpful in the HTML docs. Whether one can additionally find better representations in the raw docstring is orthogonal. Also, I believe it's helpful to start with the content. If we only need/have such images in one or two places, the work for a extension may not be justifed. But having already several plots can be a motivation for the extension.

Comment on lines 1325 to 1326
The following plot illustrates the effect of the parameters:

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
The following plot illustrates the effect of the parameters:

Suggest you just remove this for now. It should be obvious what the plot is for, and is less distracting for folks who can't see the plot.

Copy link
Member Author

Choose a reason for hiding this comment

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

ok

@github-actions github-actions bot removed the Documentation: API files in lib/ and doc/api label Sep 21, 2024
@jklymak
Copy link
Member

jklymak commented Sep 21, 2024

Feel free to self merge when build done

@timhoffm timhoffm merged commit 0988fda into matplotlib:main Sep 22, 2024
43 checks passed
@timhoffm timhoffm deleted the doc-subplots_adjust branch September 22, 2024 07:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Doc]: Add figure to subplots_adjust
2 participants