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.0.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.0-py3-none-any.whl (16.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pypubplot-0.1.0.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.0.tar.gz
Algorithm Hash digest
SHA256 de08c754541125f659488d9dbc0c14184c0621c5f3f99389fa21e72fc3337f88
MD5 378f5748dd7109d8423c5a80e0c573b6
BLAKE2b-256 7a49c5158af2529e4cb8b185c10b547ad3683a08cfaca661c59ea22c77d8d37e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pypubplot-0.1.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a4067aa37348caafb86f40c41671bae198b3511e7e312158815e034c2afc7601
MD5 3921c54fe4096858f4ddbdd24e3ff9ce
BLAKE2b-256 08c5ff3b5e7e09359f1a2d6100fc035630f48b396e38a39e14f241048385f367

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