Skip to main content

p9beeswarm

p9beeswarm provides beeswarm-style geoms for plotnine, modelled after the R ggbeeswarm package. The distribution also exposes the upstream algorithm compatibility modules as beeswarm and vipor, mirroring the corresponding R packages.

Installation

Install p9beeswarm from PyPI with:

python -m pip install p9beeswarm

Usage

import plotnine as p9
from plotnine.data import penguins
from p9beeswarm import geom_quasirandom

penguins_plot = (
    p9.ggplot(penguins.dropna(subset=["species", "body_mass_g"]),
              p9.aes("species", "body_mass_g", color="species"))
    + geom_quasirandom(width=0.35)
    + p9.labs(
        title="Penguin body mass by species",
        x="Species",
        y="Body mass (g)",
    )
    + p9.theme_bw()
)

Rendered output:

Penguin body mass beeswarm plot by p9beeswarm

The side-by-side ggbeeswarm examples recreate the upstream README plots with both the Python and R implementations. Render them with:

quarto render docs/ggbeeswarm-examples.qmd

The README figure is generated by docs/update_readme_figure.py. If you change the example above, regenerate the image with:

uv run python docs/update_readme_figure.py

Upstream R tools

p9beeswarm is heavily inspired by the following upstream R packages. The Python implementations and compatibility tests follow their algorithms and plotting behavior:

Package License Authors
beeswarm Artistic License 2.0 Aron Eklund, James Trimble, et al.
vipor GPL (>= 2) Scott Sherrill-Mix, Erik Clarke, et al.
ggbeeswarm GPL (>= 3) Erik Clarke, Scott Sherrill-Mix, Charlotte Dawson, et al.

License

p9beeswarm is licensed under the GNU GPLv3 or later.

Testing

The package is managed with [uv]. The core test suite covers the beeswarm and vipor compatibility modules, along with the plotnine position/geom integration:

uv run --extra test pytest

Upstream comparison tests

Beyond the core suite, the tests include parity checks against the original R packages. These tests use rpy2 to call the upstream R implementations and assert that the Python results match numerically:

uv run --extra test --extra r-test pytest

The R dependencies are pinned in renv.lock and restored by the GitHub Actions workflow with r-lib/actions/setup-renv. To update the pinned versions, run these commands from the repository root:

Rscript -e 'if (!requireNamespace("renv", quietly = TRUE)) install.packages("renv", repos = "https://cloud.r-project.org")'
Rscript -e 'renv::restore(prompt = FALSE)'
Rscript -e 'renv::update(c("beeswarm", "vipor", "ggbeeswarm", "ggplot2"), prompt = FALSE)'
Rscript -e 'renv::snapshot(prompt = FALSE)'

Review the resulting renv.lock diff, run the upstream comparison tests, and commit the updated lockfile along with any dependency changes.

Type checking

Type-check using mypy.

uv run --extra test --extra r-test mypy src/ tests/

Metadata

Release files for p9beeswarm 0.2.1

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

Source distribution (sdist)

Source distribution for p9beeswarm 0.2.1
File Size Uploaded
p9beeswarm-0.2.1.tar.gz 29.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for p9beeswarm 0.2.1
File Interpreter ABI Platform
p9beeswarm-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 61.9 kB

Release files / p9beeswarm-0.2.1.tar.gz

Download URL p9beeswarm-0.2.1.tar.gz
Size 29.8 kB
Tags Source
SHA-256 checksum
How to use checksums
41fbece61d552fa9a217cbcf90aa138287d259d78ac6cdede8d60f92e7f7945b
BLAKE2b-256 checksum
How to use checksums
35c9e3aad21cc20dd93c05114242c0ef16cce7e1b41d3285472e4b69c723c513
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / p9beeswarm-0.2.1-py3-none-any.whl

Download URL p9beeswarm-0.2.1-py3-none-any.whl
Size 32.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ad549136acf1efbbde0116215e19934960d103883dadee294cae90f05bc66e0d
BLAKE2b-256 checksum
How to use checksums
ee185b55cca4bb44aef4ded80a99eadba2a083daece397f524e6ee32342a74b4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

0.3.0

2 release files

This release

0.2.1 This release

2 release files

0.2.0

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