DOC: Add thumbnail for multipage_pdf gallery example#31308
DOC: Add thumbnail for multipage_pdf gallery example#31308story645 merged 1 commit intomatplotlib:mainfrom
Conversation
|
CI checks failed — I'm investigating the error. Please let me know if you can see the issue from your end or how can i resolve it. Thank you! |
|
The doc build failure appears to be a problem with linking to pandas' documentation so not caused by this PR. However, the build was successful enough that we can look at the relevant thumbnails here: Multpage PDF is still showing the default thumbnail, not the one you are trying to add. I'm also not sure how useful the proposed image is. If a user is actively looking for guidance how to make a multipage pdf, will a line plot indicate that this is the place to click? |
|
Hey @AMAN194701, I took a look at why the thumbnail isn't showing up in the CI build. The issue is that Here's the fix — just move the directive after the imports: -# sphinx_gallery_thumbnail_path = '_static/multipage_pdf_thumbnail.png'
"""
=============
Multipage PDF
=============
...
"""
import datetime
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.backends.backend_pdf import PdfPages
+
+# sphinx_gallery_thumbnail_path = '_static/multipage_pdf_thumbnail.png'Regarding @rcomer's point about the thumbnail image — that's a fair consideration. Since this example produces three different plots saved into a PDF, the "Page One" line plot does represent what the example actually generates. But it might also be worth following the discussion on #17479 about whether a custom default thumbnail via |
|
The thumbnail is now showing correctly in the built docs as you can see here: https://output.circle-artifacts.com/output/job/cf9ec523-efed-4d19-8358-c87be23e2f6c/artifacts/0/doc/build/html/gallery/misc/index.html. The fix was to move the sphinx_gallery_thumbnail_path directive to after the imports as suggested by @Ker102. The CI failure appears to be the pre-existing pandas documentation 404 issue as mentioned by @rcomer, not related to my changes. |
I dunno, propose examples of both and see what folks like? I'm sorry that's more work, but this is one of those things I doubt anyone will have strong opinions on until they see things to have opinions on. |
|
Thank you @story645! I'll try both and share here so everyone can give feedback. |
Yes |
4c48692 to
760b7f9
Compare
|
Here are both options for feedback! option 1 - custom multipage pdf design (already showing in PR build): [ https://output.circle-artifacts.com/output/job/6d1d0642-aa09-49cb-a776-5e1e4f04a444/artifacts/0/doc/build/html/gallery/misc/index.html ]
option 2 - simple no preview placeholder: which one works better? @story645 |
|
I like option 1. Could this be an svg so that it also looks good on high-res screens? To be checked whether sphinx-gallery supports this. |
|
Thanks @timhoffm for the suggestion!! |
760b7f9 to
f09cdb3
Compare
|
Thanks @timhoffm and @story645 for the suggestion ! I checked whether Sphinx-Gallery supports SVG thumbnails — it does. Converted the thumbnail from PNG to SVG so it renders sharply on high-res screens. And here's the gallery page from the CI build: https://output.circle-artifacts.com/output/job/445260f0-2a71-4926-ab4a-75e23f438a5f/artifacts/0/doc/build/html/gallery/misc/index.html All CI checks are passing ✅ |
|
I like the new svg image but it seems quite small in the gallery compared with other images. Would reducing white space around the edges help that? |
|
Thanks @rcomer ! |
f09cdb3 to
5bb2ce0
Compare
5bb2ce0 to
453b8ab
Compare
|
Updated the thumbnail — reduced white space so it fills the card better. Here's how it looks in the CI-built gallery:
Built docs: https://output.circle-artifacts.com/output/job/887e62eb-9252-4c7a-b91b-2b6e596394f6/artifacts/0/doc/build/html/gallery/misc/index.html |
|
Thanks @story645! Yes, I made the SVG myself from scratch — it's original work. |




Problem
The multipage_pdf example does not generate a gallery thumbnail.
Cause
The example uses pdf.savefig() instead of plt.savefig(), so Sphinx Gallery cannot auto-generate a thumbnail.
Fix
Added a static thumbnail using sphinx_gallery_thumbnail_path.
Closes #17479