Busabase
Busabase is an open-source (MIT) database and workspace for AI agents — data, docs, skills, and apps in one place. Run it locally, self-host it inside your network, or use Busabase Cloud, and turn age
A unified, colourblind-safe toolkit for publication-ready statistical visualisation, built on plotnine.
DataPython · RGitHub @pablobernabeuOnlineOwner unconfirmed
Have you tried it? One tap is enough. No sign-in needed.
A unified, colourblind-safe toolkit for publication-ready statistical visualisation in Python (plotnine). The sibling of the depictr R package.
Loading the full README.
Read the full README ↗Documentation and example gallery: https://pablobernabeu.github.io/depictr-py/
A unified, colourblind-safe toolkit for publication-ready statistical visualisation, built on plotnine.
This is the Python twin of the R package of the same name, which offers the same workflow on top of ggplot2. The two share a design and most of their functions. Many of the R functions' arguments have yet to be ported, and the Status section below lists where the two differ.
A grouped density (the default palette is a colourblind-safe set based on Okabe-Ito) and Kaplan-Meier survival curves with a log-rank test and a number-at-risk table, both from a single function call:
There is more in the example gallery.
These two use a couple of extra options (a title, legend_inside) shown in the
Getting started
guide, while the short tour below keeps its calls minimal.
Python already has an excellent plot for almost any statistical task, but those plots live in different packages with different defaults. A single figure set for a paper might draw on seaborn, scikit-learn, statsmodels, lifelines and ArviZ, each with its own look, its own API and its own colour scheme, and only one of those defaults to colourblind-safe colours. Making the set consistent and accessible then means repeating the same theming by hand on every plot.
depictr does that work once. It gives the whole workflow one theme, one
colourblind-safe palette and one calling convention, and returns plotnine
objects you can keep extending with +. 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.
The default palette is based on the Okabe-Ito set, and the package puts that choice to a test. It ships a simulator of colour-vision deficiency based on the model of Machado, Oliveira and Fernandes (2009), and a CIEDE2000 colour-difference test that measures how far apart the palette's colours stay under each deficiency:
import depictr as dp
dp.palette_safety()
# {'min_delta_e': ..., 'by_condition': {'normal': ..., 'protan': ...,
# 'deutan': ..., 'tritan': ...}, 'worst_condition': ..., 'worst_pair': ...,
# 'safe': True, 'threshold': 5.0}
The guarantee belongs to the eight built-in colours. A plot with more than
eight groups has to interpolate between them, and the interpolated colours no
longer clear the distance threshold, so depictr_palette warns when it is asked
for a ninth. Facet the groups, or map them to the sequential ramp, when a figure
needs more.
A safe palette is not a safe figure, though. Once a plot has been extended with
your own scale, shrunk to fit a journal column, or asked to distinguish groups by
colour alone, the palette's guarantee no longer describes what a reader will see.
check_figure audits the plot you are about to submit and reports what it
measured beside the threshold it was measured against, so each verdict can be
argued with:
p = dp.explore_distribution(dp.lexical_decision(), "RT", group="condition")
dp.check_figure(p, width_cm=8.9)
It measures colour separability under each dichromacy and in greyscale, the
smallest text size at the width the figure will be printed at, the WCAG contrast
of text and geometry against their backgrounds, and whether any distinction rests
on colour alone. The size check covers the text drawn inside the panel as well as
around it, and the contrast check covers the text around it alone. For a figure
saved at its final width, give that width as both width_cm and
render_width_cm, or neither, or let save_plot(check=True) audit it at the
width it saves. A journal that caps text size, as Nature does at 7 pt, can be
held to its cap with max_text_pt. The audit leaves continuous colour scales
alone, and the colour rows of a heatmap say so. For those, prefer a
perceptually ordered map such as viridis or the package's sequential and
diverging ramps.
This is the beginning of the README. Read the rest at the original. Read the full README ↗