Skip to main content

Python port of the R patchwork package

Project description

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: selfself.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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

patchwork_python-1.3.2.9000.post1.tar.gz (3.1 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

patchwork_python-1.3.2.9000.post1-py3-none-any.whl (3.0 MB view details)

Uploaded Python 3

File details

Details for the file patchwork_python-1.3.2.9000.post1.tar.gz.

File metadata

File hashes

Hashes for patchwork_python-1.3.2.9000.post1.tar.gz
Algorithm Hash digest
SHA256 d4a6673f7a93e983c944afd2b58c34b4cc555bd5efdd86f3650b8e169b9cc9ac
MD5 fa241a27cdc8c0bf4312b14b0c502d3a
BLAKE2b-256 493d1f5ee8317655823f550e2a11ea52654e2a9348c7ef1da6810f2b9ef4e1d9

See more details on using hashes here.

File details

Details for the file patchwork_python-1.3.2.9000.post1-py3-none-any.whl.

File metadata

File hashes

Hashes for patchwork_python-1.3.2.9000.post1-py3-none-any.whl
Algorithm Hash digest
SHA256 a9d305d0af9fe667c7663414e6398194f2588477fd130e0af779bd348a7747ad
MD5 65299edba698477db48b409efe0bb27a
BLAKE2b-256 7a5810de401280a5535471f9d7257ed7a541a7d90a1592e087f0b3fb4473b177

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page