{"id":51298915,"url":"https://github.com/pablobernabeu/depictr-py","last_synced_at":"2026-06-30T17:30:33.950Z","repository":{"id":367418074,"uuid":"1279634227","full_name":"pablobernabeu/depictr-py","owner":"pablobernabeu","description":"A unified, colourblind-safe toolkit for publication-ready statistical visualisation in Python (plotnine). The sibling of the depictr R package.","archived":false,"fork":false,"pushed_at":"2026-06-25T22:49:36.000Z","size":98,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-26T00:10:26.830Z","etag":null,"topics":["accessibility","colorblind","data-visualization","ggplot","plotnine","plotting","python","scientific-visualization","statistics","visualization"],"latest_commit_sha":null,"homepage":"https://pablobernabeu.github.io/depictr-py/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pablobernabeu.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-06-24T21:54:06.000Z","updated_at":"2026-06-25T22:49:41.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/pablobernabeu/depictr-py","commit_stats":null,"previous_names":["pablobernabeu/depictr-py"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/pablobernabeu/depictr-py","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pablobernabeu%2Fdepictr-py","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pablobernabeu%2Fdepictr-py/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pablobernabeu%2Fdepictr-py/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pablobernabeu%2Fdepictr-py/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pablobernabeu","download_url":"https://codeload.github.com/pablobernabeu/depictr-py/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pablobernabeu%2Fdepictr-py/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34908053,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-28T02:00:05.809Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["accessibility","colorblind","data-visualization","ggplot","plotnine","plotting","python","scientific-visualization","statistics","visualization"],"created_at":"2026-06-30T17:30:32.806Z","updated_at":"2026-06-30T17:30:33.939Z","avatar_url":"https://github.com/pablobernabeu.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# depictr (Python)\n\n[![CI](https://github.com/pablobernabeu/depictr-py/actions/workflows/ci.yml/badge.svg)](https://github.com/pablobernabeu/depictr-py/actions/workflows/ci.yml)\n[![docs](https://github.com/pablobernabeu/depictr-py/actions/workflows/docs.yml/badge.svg)](https://pablobernabeu.github.io/depictr-py/)\n[![PyPI](https://img.shields.io/pypi/v/depictr)](https://pypi.org/project/depictr/)\n[![Python versions](https://img.shields.io/pypi/pyversions/depictr)](https://pypi.org/project/depictr/)\n[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/license/MIT)\n\nDocumentation and example gallery:\n\u003chttps://pablobernabeu.github.io/depictr-py/\u003e\n\nA unified, colourblind-safe toolkit for publication-ready statistical\nvisualisation, built on [plotnine](https://plotnine.org). It is the Python\nsibling of the [depictr R package](https://github.com/pablobernabeu/depictr).\n\n## Gallery\n\nA grouped density (the default palette is the colourblind-safe Okabe-Ito set) and\nKaplan-Meier survival curves with a log-rank test and a number-at-risk table,\nboth from a single function call:\n\n![Grouped density of response times by priming condition, in the Okabe-Ito palette](https://raw.githubusercontent.com/pablobernabeu/depictr-py/main/images/readme-distribution.png)\n\n![Kaplan-Meier survival curves by treatment arm, with a log-rank test and a number-at-risk table](https://raw.githubusercontent.com/pablobernabeu/depictr-py/main/images/readme-survival.png)\n\nMore in the [example gallery](https://pablobernabeu.github.io/depictr-py/).\n\n## What it is for\n\nPython already has an excellent plot for almost any statistical task, but they\nlive in different packages with different defaults. A single figure set for a\npaper might draw on seaborn, scikit-learn, statsmodels, lifelines and ArviZ,\neach with its own look, its own API and its own colour scheme, and only one of\nthose defaults to colourblind-safe colours. Making the set consistent and\naccessible then means repeating the same theming by hand on every plot.\n\ndepictr does that work once. It gives the whole workflow one theme, one\ncolourblind-safe palette and one calling convention, and returns plotnine\nobjects you can keep extending with `+`. Where a specialist package already\ncomputes a quantity well, depictr delegates to it and redraws the result under\nthe shared theme, so you keep the trusted computation and gain a coherent,\naccessible figure.\n\n## Accessibility by default\n\nThe default palette is the Okabe-Ito set, and that choice is checked rather than\nasserted. The package ships a simulator of colour-vision deficiency based on the\nmodel of Machado, Oliveira and Fernandes (2009) and a CIE-Lab distance test that\nmeasures how far apart the palette's colours stay under each deficiency:\n\n```python\nimport depictr as dp\n\ndp.palette_safety()\n# {'min_delta_e': ..., 'by_condition': {'normal': ..., 'protan': ...,\n#  'deutan': ..., 'tritan': ...}, 'safe': True, 'threshold': 10.0}\n```\n\n## Installation\n\ndepictr is on [PyPI](https://pypi.org/project/depictr/):\n\n```bash\npip install depictr            # core (plotnine, pandas, numpy)\npip install depictr[all]       # plus the optional computation back-ends\n```\n\nThe classification, model and survival plots delegate to scikit-learn,\nstatsmodels and lifelines respectively. Each is an optional dependency, so the\ncore stays light and you install only what your plots need\n(`depictr[classification]`, `depictr[models]`, `depictr[survival]`).\n\n## A short tour\n\n```python\nimport depictr as dp\n\n# Exploratory analysis\nld = dp.lexical_decision()\ndp.explore_distribution(ld, \"RT\", group=\"condition\", kind=\"both\")\n\nwb = dp.wellbeing_survey()\ndp.correlation_heatmap(wb)\ndp.missingness_map(wb)\n\n# Model estimates: a fitted model OR a tidy data frame\nimport statsmodels.formula.api as smf\n# Q() quotes \"yield\" because it is a Python keyword.\nfit = smf.ols('Q(\"yield\") ~ fertiliser + rainfall + soil_ph + treatment',\n              dp.crop_yield()).fit()\ndp.coefficient_plot(fit)\n\n# Classification: computed by scikit-learn, themed by depictr\nct = dp.clinical_trial()\ndp.roc_curve_plot(ct[\"adverse_event\"], ct[\"biomarker\"])\n\n# Survival: Kaplan-Meier with a log-rank test, in one call\ndp.survival_plot(ct[\"time\"], ct[\"event\"], group=ct[\"arm\"])\n```\n\nEvery function returns a plotnine object, so the usual grammar-of-graphics\nextensions apply:\n\n```python\nfrom plotnine import labs\n\ndp.roc_curve_plot(ct[\"adverse_event\"], ct[\"biomarker\"]) + labs(title=\"Adverse event\")\n```\n\n## The web app\n\nA Streamlit app provides a gallery and a low-friction way to try the package: it\nloads one of the bundled datasets (or a CSV you upload), draws the chosen plot,\nshows the exact Python call that produced it, and offers a colourblind-vision\ntoggle that re-renders the figure as each deficiency would be seen. Run it with:\n\n```bash\npip install depictr[app]\nstreamlit run app/streamlit_app.py\n```\n\n## Function families\n\n| Family | Functions |\n| --- | --- |\n| Theme and palette | `theme_depictr`, `scale_colour_depictr`, `scale_fill_depictr`, `depictr_palette` |\n| Accessibility | `palette_safety`, `simulate_cvd` |\n| Exploratory analysis | `explore_distribution`, `explore_categorical`, `explore_bivariate`, `scatter_trend`, `correlation_heatmap`, `missingness_map`, `ecdf_plot`, `ridgeline_plot`, `dumbbell_plot`, `outlier_plot`, `group_comparison_plot`, `raincloud_plot`, `explore_pairs` |\n| Estimation and tables | `estimation_plot` (single- or two-panel Gardner-Altman), `summary_table` |\n| Model estimates | `coefficient_plot`, `tidy_estimates`, `effects_plot`, `interaction_plot`, `compare_models`, `random_effects_plot`, `posterior_plot`, `frequentist_bayesian_plot`, `power_curve_plot` |\n| Diagnostics | `qq_plot`, `influence_plot`, `vif_plot`, `binned_residual_plot`, `residual_diagnostics_plot`, `model_report` |\n| Classification | `roc_curve_plot`, `pr_curve_plot`, `confusion_matrix_plot`, `calibration_plot`, `gain_plot`, `lift_plot`, `threshold_plot` |\n| Multivariate | `pca_plot`, `scree_plot`, `cluster_plot`, `dendrogram_plot`, `silhouette_plot` |\n| Survival | `survival_plot` (with an optional number-at-risk table) |\n| Time series | `acf_plot`, `decompose_plot`, `seasonal_plot`, `timeseries_plot` |\n| Composition | `arrange_plots`, `save_plot` |\n\n## Status\n\nThis is an early release (0.1.0), but coverage is now broad: the colourblind-safe\ntheme, the accessibility check, and the R package's plotting functions across\nevery family (EDA, estimation, model estimates, diagnostics, classification,\nmultivariate, survival and time series) are in place and tested. Multi-panel\ncomposites are built on `arrange_plots`, which uses plotnine's native plot\ncomposition: the four-panel `residual_diagnostics_plot`, the `model_report`\ndashboard, the two-panel Gardner-Altman `estimation_plot`, the\nfrequentist-over-Bayesian overlay, and the survival number-at-risk table.\n\nTwo known limitations remain. plotnine compositions have no figure-level title,\nso a grid carries its titles on each panel (the survival and estimation\ncomposites place the title on their top panel). And `optimizer_fixef_plot` from\nthe R package is not ported, as there is no clean statsmodels equivalent of\n`lme4::allFit`.\n\n## Relationship to the R package\n\nThe two are siblings, not a shared codebase. The R package targets ggplot2 and\nCRAN; this one targets plotnine and PyPI. They share the design: one accessible\ntheme across the whole workflow, model-or-data-frame input, and extensible plot\nobjects.\n\n## Licence\n\nMIT. See [LICENSE](https://github.com/pablobernabeu/depictr-py/blob/main/LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpablobernabeu%2Fdepictr-py","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpablobernabeu%2Fdepictr-py","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpablobernabeu%2Fdepictr-py/lists"}