Skip to content

Add gallery thumbnails for examples missing them#31986

Open
harshitnagar22 wants to merge 8 commits into
matplotlib:mainfrom
harshitnagar22:fix/gallery-thumbnails
Open

Add gallery thumbnails for examples missing them#31986
harshitnagar22 wants to merge 8 commits into
matplotlib:mainfrom
harshitnagar22:fix/gallery-thumbnails

Conversation

@harshitnagar22

@harshitnagar22 harshitnagar22 commented Jul 2, 2026

Copy link
Copy Markdown

PR summary

Went through the gallery examples one by one to find ones that were missing thumbnails. These were mostly _sgskip files (not executed during doc build) and a couple of regular examples that don't produce standard matplotlib figures. Added sphinx_gallery_thumbnail_path to each one.

10 Python files modified:

File Thumbnail
galleries/examples/animation/frame_grabbing_sgskip.py _static/frame_grabbing.png
galleries/examples/event_handling/ginput_manual_clabel_sgskip.py _static/ginput_manual_clabel.png
galleries/examples/event_handling/pong_sgskip.py _static/pong.png
galleries/examples/misc/font_indexing.py _static/font_indexing.png
galleries/examples/misc/hyperlinks_sgskip.py _static/hyperlinks.png
galleries/examples/misc/multiprocess_sgskip.py _static/multiprocess.png
galleries/examples/misc/print_stdout_sgskip.py _static/print_stdout.png
galleries/examples/mplot3d/rotate_axes3d_sgskip.py _static/rotate_axes3d.png
galleries/examples/mplot3d/wire3d_animation.py _static/wire3d_animation.png
galleries/examples/widgets/lasso_selector_demo_sgskip.py _static/lasso_selector_demo.png

10 new thumbnail images added to doc/_static/.

Partially addresses #17479 (adds thumbnails for ~10 of the ~25 examples/tutorials listed).

AI Disclosure

Went through the gallery examples one by one, identified the ones missing thumbnails, and added paths manually. AI helped with initial exploration and catching inconsistencies during the review cycle.

PR checklist

Add sphinx_gallery_thumbnail_path for multiple gallery examples that
were missing thumbnails because they use sgskip or don't produce
standard matplotlib figures.

Closes matplotlib#17479
@github-actions

github-actions Bot commented Jul 2, 2026

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.

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

Please use our PR template, in particular state the use of AI if applicable.

Comment on lines +9 to 10
# sphinx_gallery_thumbnail_path = "_static/frame_grabbing.png"
"""

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.

Suggested change
# sphinx_gallery_thumbnail_path = "_static/frame_grabbing.png"
"""
"""
# sphinx_gallery_thumbnail_path = "_static/frame_grabbing.png"

The comment must be in the code not in the docstring.

@scottshambaugh

Copy link
Copy Markdown
Contributor

Could you take a pass through the examples and see if others are missing? For example, https://matplotlib.org/stable/gallery/mplot3d/rotate_axes3d_sgskip.html also does not have a thumbnail

@story645

story645 commented Jul 3, 2026

Copy link
Copy Markdown
Member

Use animation (FuncAnimation) which doesn't produce a static frame

Can you explain this b/c most of our animation examples produce a thumbnail? Also, can you explain how you think your images illustrate the example they're for?

@harshitnagar22

This comment was marked as outdated.

@harshitnagar22 harshitnagar22 requested a review from timhoffm July 4, 2026 16:12
…ails

Adds thumbnails for sgskip examples and non-figure-producing examples
that are missing auto-generated gallery thumbnails.

Partially addresses matplotlib#17479
@harshitnagar22

Copy link
Copy Markdown
Author

Thanks everyone for the reviews! I've cleaned up the PR quite a bit based on the feedback:

@timhoffm — You're right about the PR template and AI disclosure. I've updated the PR description now to follow the template properly and added an AI disclosure statement. Thanks for noting that.

@scottshambaugh — I added the rotate_axes3d_sgskip thumbnail as you suggested. Good catch on that one.

@story645 — Great questions:

  1. "Most of our animation examples produce a thumbnail" — You're right that animation examples using FuncAnimation typically do produce thumbnails because sphinx-gallery captures the last rendered frame. The ones here are different:
    • frame_grabbing_sgskip uses MovieWriter directly (not FuncAnimation), bypassing the normal rendering pipeline
    • wire3d_animation uses a manual loop with time.sleep() instead of FuncAnimation, so there's no automatic frame capture
    • Both are _sgskip examples, so they're never executed during doc builds anyway
  2. "How do the images illustrate the example they're for?" — The thumbnails show a representative output frame from each example. For instance, the frame_grabbing.png shows the sine wave plot that the example generates, pong.png shows the actual pong game interface, etc.

I've also rebased the branch to keep only the thumbnail additions — no more accidental rewrites of the example code. All 10 files now contain only their original content plus the thumbnail path.

Let me know if there's anything else that needs to be addressed!

@scottshambaugh

scottshambaugh commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Hi @harshitnagar22, please do not use AI to write your comments except for direct translation. We would much prefer to see your thoughts without AI "polish"

@harshitnagar22

Copy link
Copy Markdown
Author

@scottshambaugh Got it, and sorry about that. I’ll make sure to write the comments in my own words from now on. Please let me know if there’s anything else you’d like me to change in the PR.

@story645

story645 commented Jul 8, 2026

Copy link
Copy Markdown
Member

The thumbnails show a representative output frame from each example.

Can you look through some of the previous discussions on thumbnails? My hang up here is that the representative output doesn't necessarily do a good job of illustrating why a person would want to look at the example. For example, this tells me nothing about font indexing:

image

@harshitnagar22

Copy link
Copy Markdown
Author

The thumbnails show a representative output frame from each example.

Can you look through some of the previous discussions on thumbnails? My hang up here is that the representative output doesn't necessarily do a good job of illustrating why a person would want to look at the example. For example, this tells me nothing about font indexing:

image

Good point. I see what you mean. I’ll go through the earlier thumbnail discussions and revisit this.

@harshitnagar22

Copy link
Copy Markdown
Author

@story645 — thanks for the feedback! I've updated the weak thumbnails for font_indexing, frame_grabbing, and multiprocess to better illustrate what each example does. Let me know if these work better or if you'd like any further adjustments.

@timhoffm

Copy link
Copy Markdown
Member

Please make sure images are minified.

We serve a lot of thumbnails on the examples page and don’t want to create more traffic than necessary.

Use optipng, which is used internally for the rendered example plots, or manually minify through a separate tool such as https://tinypng.com/

@timhoffm

Copy link
Copy Markdown
Member

The Lasso selector image should have a visible lasso

@timhoffm

Copy link
Copy Markdown
Member

Generally, it would be good to have a way to recreate/modify the images later. Please consider how that could be supported, e.g. through a short description/script as a comment in the example sources?

…d Minified all 9 PNG thumbnails to reduce file sizes
@harshitnagar22

Copy link
Copy Markdown
Author

@timhoffm Thanks for the feedback! I took another pass over the thumbnails and made a few updates:

  • Updated the lasso_selector_demo thumbnail to better show the interactive selection.
  • Added short description to the relevant examples.
  • Minified all 9 PNG thumbnails to keep their file sizes smaller.

Let me know if these work better or if you'd like any further adjustments.

@harshitnagar22

Copy link
Copy Markdown
Author

Hi @timhoffm and @story645, I just pushed another round of updates.

Whenever you have a chance, I'd love to hear your thoughts. If there's anything else that you'd like me to tweak, I'm happy to do it.

@story645

Copy link
Copy Markdown
Member

Whenever you have a chance, I'd love to hear your thoughts

I think the images are still a bit disconnected from the point of the figure and adding extraneous information (what does kerning have to do w/ font index? what about multiprocessing shows multiprocessing?) And the figures lack the scripts/prompts to reproduce them.

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.

Add thumbnails for tutorials/gallery where missing

4 participants