Skip to content

DOC: Add a plot to margins() to visualize the effect #28808

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 2 commits into from
Sep 13, 2024

Conversation

timhoffm
Copy link
Member

No description provided.

@timhoffm timhoffm added the Documentation: API files in lib/ and doc/api label Sep 12, 2024
@github-actions github-actions bot added topic: axes and removed Documentation: API files in lib/ and doc/api labels Sep 12, 2024
@timhoffm timhoffm added the Documentation: API files in lib/ and doc/api label Sep 12, 2024
@jklymak
Copy link
Member

jklymak commented Sep 12, 2024

This seems like a complicated example for the ApI docs? Would we not prefer just a link-out here to a standalone example?

@timhoffm
Copy link
Member Author

timhoffm commented Sep 12, 2024

This is not an example in the sense that the code is relevant. The rendered picture is. The code does not show up in the rendered docs:

https://output.circle-artifacts.com/output/job/00757267-8a4a-46fe-96a5-f087064abf30/artifacts/0/doc/build/html/api/_as_gen/matplotlib.axes.Axes.margins.html#matplotlib.axes.Axes.margins

we could alternatively embed a static image, but it's slightly simpler to adapt/maintain from code, and it's and "added feature" that an interested user can get the source via link. If you're concerned about raw docs, we could put the code into a separate file and

.. plot:: margins_illustration.py

@story645
Copy link
Member

story645 commented Sep 12, 2024

Love the idea (and we already do some of this as a note in I think arrow to explain the angles), a little concerned that the arrows overlayed with the data here are hard to read:
api-_as_gen-matplotlib-axes-Axes-margins-1 2x

Can this be stripped down to like a 3 by 4? and possibly instead of arrows, gray out or hatch the margin region like we do to explain the padding for figures?

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

New version:

grafik

and plot code separated to a file not not spam the raw docs too much.

@story645
Copy link
Member

I think that's way clearer as an explaination!

What about putting it in the gallery with a purpose: reference tag?

That way it's available for quick lookup for folks browsing the gallery and who may want the code, but also the tag indicates that this isn't intended as teaching code?

Copy link
Member

@story645 story645 left a comment

Choose a reason for hiding this comment

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

While I think it'd be cool as an example, I also don't kinda like us just having a folder for these sorta plots/might help in gallery cleanup in a different way.

@jklymak
Copy link
Member

jklymak commented Sep 13, 2024

This is probably fine, though a link would work for rendered and raw docs. However the docs are not building on this pr

@timhoffm
Copy link
Member Author

timhoffm commented Sep 13, 2024

Links sound better than they are for raw docs. A link would look like :doc:/gallery/some_subgallery/margins. You cannot do anything useful with it from an interpreter. You have to go to the browser and find out how the link translates to an URL. I claim it's then simpler to go to the browser and open the margins() docs.

Another issue with putting this into the gallery as is, is that the plot is specifically designed for the visual result, it's not an instructive code example for margins.

Generally, I believe, there's a place for "plots embedded into the docstrings". Visualizations help. Naturally, we can only do them in HTML, not in raw docs). Putting the plot code into separate files helps to keep the raw docstings readable. Note that we don't have to go with separate files in .rst docs. They are not read in raw by users, so inline .. plot:: code is fine there.

This PR specifically, makes margins() more understandable by itself. I see it as reasonable incremental improvement for that limited scope. A more complete "explanation doc" on limit handling would be useful. This is on of the topics tracked in #20984.

@story645
Copy link
Member

story645 commented Sep 13, 2024

I really need to proofread what I write and am very sorry for the confusion! I don't know how the don't got in there - I meant to say that I really like the folder for collecting these kinds of images cause I agree we need more of em. 🤦‍♀️

I just didn't merge in case you liked the gallery idea.

.

@timhoffm timhoffm added this to the v3.10.0 milestone Sep 13, 2024
@timhoffm timhoffm merged commit 42b88d0 into matplotlib:main Sep 13, 2024
43 checks passed
@timhoffm timhoffm added the Documentation: API files in lib/ and doc/api label Sep 13, 2024
@timhoffm timhoffm deleted the doc-margins branch September 13, 2024 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation: API files in lib/ and doc/api topic: axes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants