Skip to content
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

Fix missing PyGMT images in user guide #474

Merged
merged 4 commits into from
Mar 22, 2024
Merged

Conversation

santisoler
Copy link
Member

@santisoler santisoler commented Mar 12, 2024

Add hidden cell in user guide examples configuring PyGMT to use "notebook" as display method. This way jupyter-sphinx is able to render the images in the generated HTML files. This issue should be fixed upstream in PyGMT.

Relevant issues/PRs:

Fixes #473

Use `fig.show(method="notebook")` in user guide pages that use PyGMT to
generate plots. This way `jupyter-sphinx` is able to render the images
in the generated HTML files.
Copy link
Member

@leouieda leouieda left a comment

Choose a reason for hiding this comment

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

Until there is a fix on the PyGMT side, I'd recommend adding this cell to the top of the files (after the imports):

.. jupyter-execute::
   :hide-code:

   # Needed so that displaying works on jupyter-sphinx and sphinx-gallery at
   # the same time. Using PYGMT_USE_EXTERNAL_DISPLAY="false" in the Makefile
   # for sphinx-gallery to work means that fig.show won't display anything here
   # either.
   pygmt.set_display(method="notebook")

This way the code works on notebooks and terminal (setting method="notebook" doesn't). And when there is a fix, this won't change anything.

@santisoler
Copy link
Member Author

I totally agree. That's a much better solution than this one. I'll revert the previous changes and then apply the one you suggested.

Add a hidden cell in user guides that make use of PyGMT to plot maps.
This cell configures PyGMT display method to `"notebook"` in order to
fix the issue of missing figures in our docs.
@santisoler santisoler dismissed leouieda’s stale review March 22, 2024 23:11

Suggested change was applied

@santisoler santisoler merged commit caf3cc1 into main Mar 22, 2024
18 checks passed
@santisoler santisoler deleted the fix-missing-pygmt-figs branch March 22, 2024 23:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PyGMT figures are not being showed in the latest docs
2 participants