pypubplot
pypubplot is an opinionated plotting library for single-cell analysis and academic publication. Built on top of ultraplot (a matplotlib wrapper), it provides publication-ready defaults: colorblind-friendly palettes, clean axis styling, and one-call export to PNG or SVG at ≥300 DPI.
Functionality
- Ridge plots — QC metric distributions grouped by cell type or sample.
- PCA scatter — Principal components with confidence ellipses and auto-labeled clusters.
- Embeddings (UMAP / t-SNE) — Categorical or continuous overlays with L-shaped axis stubs.
- Cell composition — Horizontal stacked-bar charts for subtype proportions.
- Violin plots — Grouped distributions with jitter dots and automatic legend handling.
All functions return (fig, ax) so you can fine-tune before saving.
Setup
Install from PyPI (once published) or directly from GitHub:
pip install pypubplot
Or with uv:
uv add pypubplot
Import the library:
import pubplot
from pubplot import plot_ridge, plot_pca, plot_violinplot
from pubplot import plot_embedding_categorical, plot_cell_composition
Usage
Ridge plot
Distributions of QC metrics (e.g. % mitochondrial) grouped by cell type or sample.
from pubplot import plot_ridge
plot_ridge(
df,
group_col="louvain",
value_col="percent_mito",
title="% mitochondrial — by cell type",
xlabel="% mito",
save_path="results/qc_pct_mt_by_cell_type",
)
PCA
Scatter plot of the first two principal components with confidence ellipses and auto-adjusted labels.
from pubplot import plot_pca
plot_pca(
df,
x_col="PC1",
y_col="PC2",
color_col="louvain",
save_path="results/pca_pbmc3k",
)
UMAP / t-SNE
Categorical embeddings with cluster annotations and L-shaped axis stubs.
from pubplot import plot_embedding_categorical
plot_embedding_categorical(
df,
x_col="tSNE1",
y_col="tSNE2",
color_col="louvain",
embedding_type="tSNE",
save_path="results/tsne_pbmc3k",
)
from pubplot import plot_embedding_categorical
plot_embedding_categorical(
df,
x_col="UMAP1",
y_col="UMAP2",
color_col="louvain",
embedding_type="UMAP",
save_path="results/umap_pbmc3k",
)
Cell composition
Horizontal stacked-bar chart showing subtype proportions per sample.
from pubplot import plot_cell_composition
plot_cell_composition(
composition_df,
save_path="results/composition_8colors",
)
Violin plot
Grouped distributions with jitter dots. ≤ 8 groups get individual colours and a single-column legend; > 8 groups fall back to a uniform colour with x-axis labels.
from pubplot import plot_violinplot
plot_violinplot(
df,
group_col="louvain",
value_col="NKG7",
title="NKG7 — 5 cell subtypes",
ylabel="Expression",
save_path="results/violin_5subtypes",
)
Save format
By default all functions save to PNG at 300 DPI. Use save_fmt to control the output:
plot_pca(..., save_fmt="svg") # SVG only
plot_pca(..., save_fmt="both") # both PNG and SVG
plot_pca(..., save_fmt="png") # PNG only (default)
Palettes
Built-in colourblind-friendly palettes are available directly:
from pubplot import PUBLICATION_PALETTE, OKABE_ITO
from pubplot import build_color_map, get_cell_composition_palette
| Palette | Size | Use case |
|---|---|---|
PUBLICATION_PALETTE |
45 | General-purpose, up to 45 groups |
OKABE_ITO |
8 | Colorblind-safe categorical |
CELL_COMPOSITION_PALETTE_8 |
8 | Stacked bars (≤ 8 subtypes) |
CELL_COMPOSITION_PALETTE_13 |
13 | Stacked bars (≤ 13 subtypes) |
For developers
Clone or download the repository on your machine. Make sure you have uv installed, then run:
uv sync
This will create the virtual environment and install all dependencies (including dev dependencies like ruff, mypy, and pre-commit).
To activate the pre-commit hooks:
uv run pre-commit install
All contributions are more than welcome. Feel free to open an issue or make a PR.
Author
Faouzi Braza
Metadata
Release files for pypubplot 0.1.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pypubplot-0.1.5.tar.gz | 13.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pypubplot-0.1.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 30.3 kB
Release files / pypubplot-0.1.5.tar.gz
| Download URL | pypubplot-0.1.5.tar.gz |
|---|---|
| Size | 13.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7d5f9d52cde12c75a167c72f9dc319ac0dbd4d4147e827a99a26416d1d2bfb19
|
|
BLAKE2b-256 checksum How to use checksums |
b3153b5787230f4d00f77bc4303459dcddcaa97d39cf29c45a37291a5ff92575
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.13
|
Release files / pypubplot-0.1.5-py3-none-any.whl
| Download URL | pypubplot-0.1.5-py3-none-any.whl |
|---|---|
| Size | 16.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
43121cc7c56da84b6bca4f24b3015fe306b00168f8f4187304c2b55d98980834
|
|
BLAKE2b-256 checksum How to use checksums |
0d70d56afdde68e99b281275cbc9384ff13f63c98944088ff523f5040d0807b4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.13
|