Skip to content

depictr (Python)

A unified, colourblind-safe toolkit of publication-ready plots that span the whole analysis workflow, built on plotnine.

This is the Python sibling of the R package of the same name. Both give the whole workflow one theme, one colourblind-safe palette and one calling convention.

Get started Open the gallery Try the web app

A single figure set for a paper might otherwise draw on seaborn, scikit-learn, statsmodels, lifelines and ArviZ, each with its own defaults, its own API and its own colour scheme, and only one of those defaulting to colourblind-safe colours. depictr does that theming work once, and returns plotnine objects, so a plot can be refined further with the usual + syntax. Where a specialist package already computes a quantity well, depictr delegates to it and redraws the result under the shared theme, so you keep the trusted computation and gain a coherent, accessible figure.

Accessibility by default

The default palette is the Okabe-Ito set, and the package measures how well that choice holds up. A built-in simulator and a colour-distance test confirm that the palette stays legible under each form of colour-vision deficiency. The guarantee belongs to the eight Okabe-Ito colours. A figure with more groups than that has to interpolate between them, and depictr warns at the point of interpolation, so the interpolated colours are never passed off as safe. The guarantee also stops at hue confusion and says nothing about greyscale. check_figure measures both on the figure in front of you, along with its text size at print width and the contrast of its text and geometry. The accessibility page of the gallery renders the safety report and a full audit.

Install

depictr is on PyPI:

pip install depictr            # core (plotnine, pandas, numpy, matplotlib, scipy)
pip install depictr[all]       # plus the optional computation back-ends

The classification and survival plots delegate to optional back-ends, so the core install stays light. The model plots use statsmodels, which arrives with plotnine. The Get started guide lists the extras.

A first plot

import depictr as dp

ld = dp.lexical_decision()
p = dp.explore_distribution(ld, "RT", group="condition", kind="both")
print(show(p))
depictr plot

That figure was drawn when this page was built, as every figure on the site is, so the code above it is the code that produced it.

Where to look next

The gallery works through every family with the plots rendered, and the API reference documents each function.

Archived on Zenodo: DOI