Skip to contents

depictr is a single, consistent toolkit of publication-ready plots that span the whole analysis workflow, from a first look at the data, through model estimates and predictions, to diagnostics, uncertainty and reporting. Most packages address one part of this work, whereas depictr aims to cover it from end to end with one theme, one palette and one set of label conventions. Every plotting function returns a ggplot2 object (or a patchwork for composite panels), so a plot can be refined further with the usual + syntax.

This is the R half of a sibling pair. The Python package of the same name covers most of the same workflow on top of plotnine. Its README lists the handful of functions that have yet to be ported and the few places 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 confidence bands and a number-at-risk table, each from a single function call:

Grouped density of response times by priming condition, in the Okabe-Ito palette
Grouped density of response times by priming condition, in the Okabe-Ito palette
Kaplan-Meier survival curves by treatment arm, with confidence bands, censoring marks, a log-rank test and a number-at-risk table
Kaplan-Meier survival curves by treatment arm, with confidence bands, censoring marks, a log-rank test and a number-at-risk table

Installation

# install.packages("remotes")
remotes::install_github("pablobernabeu/depictr")

What’s in the box

The functions fall into seven families that follow the analysis workflow. Exploratory plots and a descriptive summary table open it. The model-estimate views come next (forest plots, model comparison, predictions, interactions and random effects), then residual diagnostics with the standard classification curves, and then posterior summaries and power curves. Further families cover principal components, clustering and survival, time series, and the shared theme with the accessibility checks, composition, saving and reporting helpers. The reference lists every function by family.

Heavier modelling back-ends (lme4, broom, simr) are optional (in Suggests) and used only when present. The core functions, examples, tests and vignettes run on base lm/glm and the bundled data alone.

Measured accessibility

The default palette is the Okabe-Ito set, and that choice is checked. The package ships a simulator of colour-vision deficiency based on the model of Machado, Oliveira and Fernandes (2009), and palette_safety() measures how far apart the palette’s colours stay under each deficiency.

A safe palette is not a safe figure, though, so check_figure() audits the plot you are about to submit. It measures how separable the encoding colours are under each dichromacy and in greyscale, how small the text becomes at a stated output width, how well text and geometry contrast with their backgrounds under WCAG, and whether any distinction rests on colour alone. Each row reports the value it measured next to the threshold, so a verdict can be argued with.

check_figure(explore_distribution(lexical_decision, RT, group = condition),
             width_cm = 8.9)

Two limits are worth knowing. The colourblind-safety guarantee covers the eight base colours, and past those the palette interpolates, with a warning from depictr_palette(). The guarantee is also confined to hue confusion: in greyscale the palette’s orange and sky blue differ by only 0.79 in CIE lightness, so they print as the same grey. A figure that may be printed in black and white wants fewer groups, a sequential palette, or a redundant shape or line type.

A first plot

library(depictr)

fit <- lm(yield ~ rainfall + fertiliser + soil_ph + treatment, data = crop_yield)
coefficient_plot(fit, order = "descending")

The Get started article walks through the whole workflow, from exploration to diagnostics and reporting.

Bundled data

Five reproducibly simulated datasets (lexical_decision, wellbeing_survey, crop_yield, clinical_trial and monthly_sales) ship with the package and power every example and vignette. Each is documented under its own name and described in the Get started article, and all are generated by data-raw/generate_datasets.R with fixed seeds.

Learn more

Each vignette takes one stretch of the workflow and works through it on the bundled data.

How depictr relates to other packages

depictr aims for breadth and consistency across the workflow, and it complements the specialised packages. Several of those remain the better choice for a deeper treatment of any one area, among them ggstatsplot (statistical details on plots), sjPlot and the easystats family (see, parameters, performance), marginaleffects / ggeffects (predictions), GGally (pairs), factoextra (PCA and clustering), survminer (survival), feasts / ggfortify (time series), ggdist / dabestr (distributions and estimation) and bayesplot / tidybayes (Bayesian). depictr offers one consistent default for all of these tasks within a single package.

Automated maintenance

depictr draws on a number of plotting and modelling packages, so scheduled GitHub Actions keep it healthy between releases. A daily job checks the package and its full test suite against both the current and the development versions of its dependencies, and a weekly job checks every URL in the documentation. On top of those, R CMD check runs on every push across Linux, macOS and Windows.

Citation

citation("depictr") gives the preferred reference. The About page carries the same citation with a BibTeX entry and a short note on the developer, and the repository ships CITATION.cff for the Cite this repository button on GitHub. The methods the package implements are cited in the relevant help pages and vignettes, drawing on a single bibliography at inst/REFERENCES.bib.

Licence

MIT (c) Pablo Bernabeu. See the licence.

Contributing

Issues and pull requests are welcome. The contributing guide describes the development setup and the conventions the package follows, and everyone taking part is asked to honour the Code of Conduct.