Skip to main content

patchwork-python

PyPI

Python port of the R patchwork package.

patchwork lets you compose multiple ggplot figures into a single layout using arithmetic-style operators — same idea here, same operators, on top of ggplot2-python:

import patchwork  # installs the | / + - dunders on GGPlot
from ggplot2_py import ggplot, aes, geom_point

p1 = ggplot(df) + geom_point(aes("x", "y"))
p2 = ggplot(df) + geom_point(aes("x", "z"))

p1 | p2          # side-by-side
p1 / p2          # stacked
(p1 | p2) / p3   # nested

Where it fits in the Bio-Babel R-port stack

patchwork-python    <-- this repo: composing ggplots
        |
        +-- ggplot2-python      grammar of graphics
        +-- rgrid-python        viewport / unit / Cairo backend
        +-- gtable-python       layout-aware grob tables
        +-- scales-python       scale transformations
        +-- great_tables        (optional) backend for wrap_table()

Install

pip install patchwork-python
pip install "patchwork-python[tables]"   # adds great_tables for wrap_table()

Figure size

Jupyter's _repr_png_ has no current graphics device, so render size lives on the plot object. Defaults are 7.0 × 5.0 in @ 150 dpi (patchwork/_display.py).

pw = p1 | p2
pw.fig_width = 12
pw.fig_height = 8
pw.fig_dpi = 200
pw   # renders at 12×8 @ 200 dpi

Patchwork._repr_png_ resolves hints in this order: self → self.plot → defaults. So p.fig_width = 12; p | q propagates without re-setting on the wrapper. A bare Patch reads from its inner plot only (Patch.__slots__ blocks per-instance attrs).

R contrast: none. R routes size through the active graphics device (png(), knitr chunk options, RStudio plot pane). The fig_* protocol is a Python-only carry-over from ggplot2_py.GGPlot.

Documentation

Tutorials are mirrored to docs/tutorials/ and rendered via mkdocs:

pip install -e ".[docs]"
mkdocs serve

Release files for patchwork-python 1.3.2.9000.post1

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

Source distribution (sdist)

Source distribution for patchwork-python 1.3.2.9000.post1
File Size Uploaded
patchwork_python-1.3.2.9000.post1.tar.gz 3.1 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for patchwork-python 1.3.2.9000.post1
File Interpreter ABI Platform
patchwork_python-1.3.2.9000.post1-py3-none-any.whl Python 3 none any Details

Total release size: 6.1 MB

Release files / patchwork_python-1.3.2.9000.post1.tar.gz

Download URL patchwork_python-1.3.2.9000.post1.tar.gz
Size 3.1 MB
Tags Source
SHA-256 checksum
How to use checksums
d4a6673f7a93e983c944afd2b58c34b4cc555bd5efdd86f3650b8e169b9cc9ac
BLAKE2b-256 checksum
How to use checksums
493d1f5ee8317655823f550e2a11ea52654e2a9348c7ef1da6810f2b9ef4e1d9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.15

Release files / patchwork_python-1.3.2.9000.post1-py3-none-any.whl

Download URL patchwork_python-1.3.2.9000.post1-py3-none-any.whl
Size 3.0 MB
Tags Python 3
SHA-256 checksum
How to use checksums
a9d305d0af9fe667c7663414e6398194f2588477fd130e0af779bd348a7747ad
BLAKE2b-256 checksum
How to use checksums
7a5810de401280a5535471f9d7257ed7a541a7d90a1592e087f0b3fb4473b177
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.15

Release history Release notifications | RSS feed

This release

1.3.2.9000.post1 This release

2 release files

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