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.
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:
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:
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.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 | |
|---|---|---|---|
| p9beeswarm-0.2.0.tar.gz | 29.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| p9beeswarm-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 60.9 kB
Release files / p9beeswarm-0.2.0.tar.gz
| Download URL | p9beeswarm-0.2.0.tar.gz |
|---|---|
| Size | 29.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1426dc42f0257ba1516fc5105514ad4b2239a4f86e34092f0734d16562f7a008
|
|
BLAKE2b-256 checksum How to use checksums |
8bcb3ea962280b8bb115ae1b232614f8eb189bf3879ab3ea3a2418a406958542
|
| 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.0-py3-none-any.whl
| Download URL | p9beeswarm-0.2.0-py3-none-any.whl |
|---|---|
| Size | 31.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cdff6d3850f0de7ffb25ebf82026016e297dbbc9f38e14378d00e0fa28f8e32a
|
|
BLAKE2b-256 checksum How to use checksums |
7be795cbf87c269127574d36cb4023cb23fdda67c50d6610565d06e204acfa18
|
| 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}
|