API reference#

Theme and palette#

theme_depictr

Return the depictr plotnine theme.

scale_colour_depictr

A discrete colour scale drawn from depictr.palette.depictr_palette().

scale_fill_depictr

A discrete fill scale drawn from depictr.palette.depictr_palette().

legend_inside

Theme fragment that moves the legend into the plotting area.

depictr_palette

Return a depictr palette.

depictr_brand

Return the depictr brand colour as a hex string.

depictr_accent

Return the depictr accent colour as a hex string.

Accessibility#

palette_safety

Check that a palette stays distinguishable under each deficiency.

simulate_cvd

Simulate how a palette appears under a colour-vision deficiency.

Exploratory analysis#

explore_distribution

Plot the distribution of a numeric variable, optionally split by a group.

explore_categorical

Bar chart of a categorical variable, optionally grouped (dodged).

explore_bivariate

Plot the relationship between two columns, choosing the plot from their types.

scatter_trend

Scatter plot with a fitted trend line and confidence band.

correlation_heatmap

Heatmap of pairwise Pearson correlations among numeric columns.

missingness_map

Tile map of missing values, one column per variable and one row per record.

ecdf_plot

Empirical cumulative distribution function, one step curve per group.

ridgeline_plot

Overlapping densities, one ridge per group level.

dumbbell_plot

Dumbbell plot pairing two group values per category.

outlier_plot

Box plot of one variable with outliers flagged in the accent colour.

group_comparison_plot

Group means with confidence intervals over the raw points.

raincloud_plot

Raincloud plot of a numeric variable, optionally split by a group.

explore_pairs

Scatter-plot matrix over a few numeric columns.

Estimation and tables#

estimation_plot

Cumming-style estimation plot of mean differences.

summary_table

Build a "Table 1" descriptive summary.

Model estimates#

coefficient_plot

Forest (dot-and-whisker) plot of model coefficients.

tidy_estimates

Coerce a fitted model or an estimate table into one tidy frame.

effects_plot

Predicted response as one predictor varies, with a confidence band.

interaction_plot

Predicted response across x for each level of a categorical group.

compare_models

Dodged forest comparing each coefficient across several models.

random_effects_plot

Caterpillar plot of the predicted random effects (BLUPs).

posterior_plot

Forest plot of posterior (or bootstrap) draws.

frequentist_bayesian_plot

Overlay a frequentist estimate against a Bayesian posterior per term.

power_curve_plot

Line plot of statistical power against sample size.

Diagnostics#

qq_plot

Normal quantile-quantile plot of the residuals, with a reference line.

influence_plot

Bubble plot of studentised residuals against leverage.

vif_plot

Horizontal bar chart of the variance inflation factor per predictor.

binned_residual_plot

Binned residual plot for a binomial GLM (Gelman & Hill, 2007).

residual_diagnostics_plot

Four-panel residual report for a fitted OLS or GLM.

model_report

One-figure dashboard pairing the coefficient plot with key diagnostics.

Classification#

roc_curve_plot

ROC curve with the area under the curve (AUC) annotated.

pr_curve_plot

Precision-recall curve with the average precision (AP) annotated.

confusion_matrix_plot

Confusion-matrix heatmap.

calibration_plot

Reliability (calibration) curve of predicted vs observed frequencies.

gain_plot

Cumulative gains chart: positives captured as more of the ranked population is targeted.

lift_plot

Cumulative lift chart.

threshold_plot

Sensitivity, specificity, precision and F1 across the decision threshold.

Multivariate#

pca_plot

PCA biplot: observations on the first two components, with loading arrows.

scree_plot

Scree plot: variance explained per component, with the cumulative line.

cluster_plot

k-means clusters drawn on the first two principal components.

dendrogram_plot

Hierarchical-clustering dendrogram drawn from a scipy linkage.

silhouette_plot

Silhouette widths per observation, grouped and ordered by cluster.

Survival#

survival_plot

Kaplan-Meier survival curves, optionally by group, with a log-rank test.

Time series#

acf_plot

Autocorrelation or partial autocorrelation as a stem plot.

decompose_plot

Seasonal decomposition as a stacked, facetted figure.

seasonal_plot

Seasonal subseries plot: value by position in the period, one line per cycle.

timeseries_plot

The series as a line, optionally with a rolling-mean overlay.

Composition and data#

arrange_plots

Arrange several plots into one composed figure.

save_plot

Save a depictr/plotnine plot at publication resolution.

crop_yield

A field trial with a genuine fertiliser-by-treatment interaction.

wellbeing_survey

A cross-sectional survey with informative missingness in income.

lexical_decision

A priming reaction-time/accuracy experiment.

clinical_trial

A two-arm trial with separating survival curves and a rare adverse event.