Skip to main content

Add your description here

Project description

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

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

pypubplot-0.1.3.tar.gz (13.6 kB view details)

Uploaded Source

Built Distribution

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

pypubplot-0.1.3-py3-none-any.whl (16.9 kB view details)

Uploaded Python 3

File details

Details for the file pypubplot-0.1.3.tar.gz.

File metadata

  • Download URL: pypubplot-0.1.3.tar.gz
  • Upload date:
  • Size: 13.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.13

File hashes

Hashes for pypubplot-0.1.3.tar.gz
Algorithm Hash digest
SHA256 ccdf2c9e86d4970778e803c121c04fc26f14ec8948c74508db63394b3e8d56fe
MD5 fdbc7176dd2309946104e91f62d8c93e
BLAKE2b-256 dce959e4e391d2e1c8345b81531a828ab31071f06f577b8fe5282182d7e7447c

See more details on using hashes here.

File details

Details for the file pypubplot-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: pypubplot-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 16.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.13

File hashes

Hashes for pypubplot-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 fa7ff90113ad6a9854d18586b8ad04def1ec24c89e9e304d3538e4ad8e899920
MD5 377165737632bd5d0352d0d46534f70d
BLAKE2b-256 cc436b01fd3be976f05b39e276b62b1e8df76df18ff3b9290a2ea23ea1ac2c60

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