Skip to main content

figpress-bokeh

A paper's figures in Bokeh. You write a figure once, and it gives both the print figure the paper publishes (a PDF) and a matching interactive web figure, with hover values, legend toggles, and light and dark themes. The web figure never disagrees with the paper.

Part of the figpress family, next to figpress-plotly. In early development: the API may still change between releases.

pip install figpress-bokeh       # printing PDFs needs Chrome or Chromium

A figure

A figure is plain Bokeh, written as a function of the target ("pdf" or "web"), with every size in points:

import figpress_bokeh as fb
from bokeh.models import Range1d
from bokeh.plotting import figure

STYLE = fb.Style(fonts=fb.dejavu(), size=7, label=8)   # the paper's fonts and print settings, in pt

@fb.figure(page=(242, 170), style=STYLE, margins=(38, 6, 8, 28))
def rotation(target):
    p = figure(x_range=Range1d(0, 20), y_range=Range1d(0, 300))
    p.line(r, v, line_width=fb.pt(1), tags=["fb:group:model"])
    fb.text(r"$v_{\rm c}$ (km s$^{-1}$)", 12, 80, 8, ha="center", angle=90)   # at a page point (pt)
    fb.text("Model", 15, 230, 7, panel=p, va="bottom")                       # at a data point
    return p

rotation.write_pdf("src/tex/figures/rotation.pdf")                 # the paper's figure
rotation.write_web("site/rotation/", single_file="rotation.html")  # its web figure
  • The PDF is one page of exactly the size given, with only the style's fonts embedded (as TrueType, never Type 3). In a showyourwork paper it is the script's output.
  • The web figure is the same figure drawn at its column's width: a folder (page, figure data, fonts, and BokehJS and the runtime at pinned versions; serve it over http) and one self-contained HTML file that opens from disk. Nothing is loaded from another host.
  • The style is a Bokeh theme: whatever a figure sets on a model itself wins.
  • Text: fb.text() sets a label in the paper's fonts, mathematics included ($\lambda_{\rm C}$, Greek, sub- and superscripts, \times, \in, km s$^{-1}$), aligned as matplotlib aligns text. fb.legend() draws a legend as matplotlib draws one.

Several panels

@fb.figure(page=(360, 252), fonts=fb.dejavu(), margins=(40, 8, 84, 34))
def grid(target):
    a, b, c, d = (figure(x_range=Range1d(0, 10), y_range=Range1d(-1.6, 1.6)) for _ in range(4))
    panels = fb.panels([[a, b], [c, d]], margins=(40, 8, 84, 34), gaps=(12, 12),
                       share_x="col", share_y="row", labels="(a)")
    for p in panels:
        fb.ticklabels(p, "x", [0, 5, 10], pad=7)
        fb.axis_label(p, "x", "Time $t$")
    return panels

Each panel's frame lands exactly where the grid (or an explicit list of frames) puts it. Shared axes share one range, and only the outer panels get tick labels and titles. fb.ticklabels() and fb.axis_label() place them as matplotlib does; Bokeh's own pull the end labels inward.

On the web

  • Hover: declare it as in any Bokeh figure (HoverTool).
  • Groups: tag renderers fb:group:<name>. Clicking an entry of fb.legend() (or of Bokeh's own legend with click_policy="hide") hides the whole group, in every panel. The reader's choices survive resizing and theme changes.
  • Light and dark: greys (black and white included) follow the theme, the website's dark palette; every other colour stays the paper's. The theme is a ?theme=dark|light on the page, else the page's data-theme, else the system's.

Porting a matplotlib figure

When a figure already in the paper moves to figpress-bokeh, measure the new PDF against it:

figpress-bokeh compare new.pdf paper-figure.pdf --tol 1 --overlay overlay.png

It matches every piece of text by content and every panel's frame from the image, reports each offset in points, and writes an overlay. examples/bands/ and examples/grid/ match their matplotlib references within 0.6 pt.

Command line

figpress-bokeh build figures.py:grid --out build/                 # grid.pdf, grid/, grid.html
figpress-bokeh build figures.py:grid --out build/ --target pdf
figpress-bokeh compare build/grid.pdf reference.pdf --tol 1 --overlay overlay.png

Limits

  • fb.text() covers the LaTeX figures use, not all of LaTeX; an unsupported command is named.
  • Figures cannot outline text (text_outline_color): Chrome prints outlined text as Type 3 fonts.
  • Bokeh draws a plot's outline up to 0.25 pt inside its frame on the top and right edges.
  • Printing uses Chrome with its own profile in figpress-bokeh's cache folder; prints take turns (a file lock), so parallel builds are safe. It works on macOS and Linux.
  • There are no controls (sliders) yet; figpress-plotly has them.

Developing

uv run pytest                       # the library, both examples' PDFs against their references
node --test "tests/*.test.mjs"      # the web runtime
uv run pytest -m smoke              # the web figures in a browser (Playwright)

Spec Kit features are under specs/; releases are dated, see AGENTS.md.

Licence

MIT.

Metadata

Release files for figpress-bokeh 2026.11.24

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for figpress-bokeh 2026.11.24
File Size Uploaded Provenance Actions
figpress_bokeh-2026.11.24.tar.gz 29.8 kB With provenance Details for figpress_bokeh-2026.11.24.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for figpress-bokeh 2026.11.24
File Interpreter ABI Platform Actions
figpress_bokeh-2026.11.24-py3-none-any.whl Python 3 none any Details for figpress_bokeh-2026.11.24-py3-none-any.whl

Total release size: 66.3 kB

Release files / figpress_bokeh-2026.11.24.tar.gz

Download URL figpress_bokeh-2026.11.24.tar.gz
Size 29.8 kB
Tags Source
SHA-256 checksum
How to use checksums
38bbc9449d7cf1b2fa32d1582b154f7328a7ec4e7c0debb6ee68135c6e520805
BLAKE2b-256 checksum
How to use checksums
291712c9120117dc89fbf07e140bc1d60a58654b0261c5c3e497b19e24f3387f
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 25, 2026.

Transparency log

Release files / figpress_bokeh-2026.11.24-py3-none-any.whl

Download URL figpress_bokeh-2026.11.24-py3-none-any.whl
Size 36.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
78e50f0f2dd83e5c2191fe7dc61c5c386d7f273d531a9cf56afa80e887137636
BLAKE2b-256 checksum
How to use checksums
45fdd5c4cbc472fb39106d9154c5612f177316ebd79b58c5c999e5a83a6eb8bb
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 25, 2026.

Transparency log

Security for figpress-bokeh 2026.11.24

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.

Select from 2 files

Attestation for figpress_bokeh-2026.11.24.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 25, 2026.

Transparency log

A 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.

Release history Release notifications | RSS feed

This release

2026.11.24 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page