sphinx-fplotlib-gallery
A Sphinx extension that lets Sphinx-Gallery build, run and show Fortran examples that draw with fplotlib.
Each example is a Fortran program. The extension builds all of them with fpm, runs each one in a scratch directory, and embeds every picture it saved under the code block that saved it, the same way Sphinx-Gallery shows matplotlib figures.
Install
pip install sphinx-fplotlib-gallery
Building the gallery also needs fpm and a Fortran compiler on PATH.
Without them, pass -D plot_gallery=0 to sphinx-build: the examples are then
rendered and highlighted but not run.
Configure
In conf.py:
extensions = [
"sphinx_gallery.gen_gallery",
"fplotlib_gallery",
]
sphinx_gallery_conf = {
"examples_dirs": ["gallery"], # where the .f90 examples live
"gallery_dirs": ["auto_gallery"], # where the generated pages go
"filename_pattern": r"[\/]plot_", # which examples to run
"image_scrapers": ("fplotlib_gallery.fplotlib_scraper",),
"reset_modules": (),
"inspect_global_variables": False,
}
The Fortran suffixes are registered with Sphinx-Gallery automatically.
Where fplotlib comes from
fplotlib_gallery_root is the fpm package the documentation belongs to. It
defaults to the parent of the Sphinx source directory.
- Documenting fplotlib itself: the examples build against the checkout.
- Documenting another fpm package: the examples depend on that package by path, and on fplotlib too unless the package already depends on it.
- No
fpm.tomlthere: the examples depend on fplotlib alone.
In the last two cases fplotlib comes from fplotlib_gallery_fplotlib, an fpm
dependency spec written as a TOML inline value. It defaults to the main
branch on GitHub. Pin it for reproducible documentation:
fplotlib_gallery_fplotlib = '{ git = "https://github.com/fortran-lang/fplotlib", tag = "v0.1.0" }'
Other settings
| Setting | Default | Meaning |
|---|---|---|
fplotlib_gallery_dependencies |
{} |
Extra fpm dependencies, as {name: TOML value}, e.g. {"stdlib": '"*"'} |
fplotlib_gallery_compiler |
fpm's choice | Value passed to fpm --compiler |
fplotlib_gallery_fpm_flags |
autodetected | Value passed to fpm --flag |
fplotlib_gallery_fpm |
"fpm" |
The fpm executable |
fplotlib_gallery_build_dir |
<srcdir>/_build/fplotlib-gallery |
Where the generated fpm project is built |
fplotlib_gallery_timeout |
600 |
Seconds allowed per fpm call and per example |
fplotlib_gallery_save_functions |
["savefig", "save_animation"] |
Calls whose filename ties a picture to a code block |
Write an example
Name the file to match filename_pattern, for example plot_sine.f90. Start it
with a ! comment block holding the page title and introduction. Later prose
starts with ! %% and splits the code into blocks.
! Sine wave
! =========
!
! A first plot.
program plot_sine
use fplotlib
implicit none
integer :: i
real(8) :: x(100)
x = [(0.1d0 * i, i = 0, 99)]
! %%
! Each picture appears under the block that saved it.
call plot(x, sin(x), "b-")
call savefig("sine.svg")
end program plot_sine
Every format fplotlib writes works, including animated GIF from
save_animation. Each example runs in an empty directory of its own.
Troubleshooting
On Windows, fpm can fail with Cannot open file '...o.digest' when the docs
live in a deep directory, because its build paths exceed the 260-character
limit. Point fplotlib_gallery_build_dir at a short path such as
C:/tmp/fplotlib-gallery, or enable long paths in Windows.
License
MIT
Metadata
Release files for sphinx-fplotlib-gallery 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sphinx_fplotlib_gallery-0.1.0.tar.gz | 13.7 kB | With provenance | Details for sphinx_fplotlib_gallery-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sphinx_fplotlib_gallery-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for sphinx_fplotlib_gallery-0.1.0-py3-none-any.whl |
Total release size: 28.1 kB
Release files / sphinx_fplotlib_gallery-0.1.0.tar.gz
| Download URL | sphinx_fplotlib_gallery-0.1.0.tar.gz |
|---|---|
| Size | 13.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c04a1de910995bf2838bd5f243c7b96789893a25dd68b077f52e8a465eec2737
|
|
BLAKE2b-256 checksum How to use checksums |
fa775863b67de1cdb67331b4cc5cda48469bbd8f81b426163db20385e168af82
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 1, 2026.
Transparency logRelease files / sphinx_fplotlib_gallery-0.1.0-py3-none-any.whl
| Download URL | sphinx_fplotlib_gallery-0.1.0-py3-none-any.whl |
|---|---|
| Size | 14.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0f5a9755b1b8f048699d579a77ab18038951b38d091dc3dca56696bd107743f1
|
|
BLAKE2b-256 checksum How to use checksums |
49db88f62dfa91fff65ef07ce0345b48074e1e77baee69efa520946b6c581b54
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 1, 2026.
Transparency logSecurity for sphinx-fplotlib-gallery 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for sphinx_fplotlib_gallery-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 1, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.