Metadata-Version: 2.4
Name: tidydraws
Version: 0.4.2
Project-URL: Homepage, https://github.com/drbenvincent/tidydraws
Project-URL: Repository, https://github.com/drbenvincent/tidydraws
Project-URL: Issues, https://github.com/drbenvincent/tidydraws/issues
Project-URL: Documentation, https://drbenvincent.github.io/tidydraws/
Author: Benjamin Vincent
License-Expression: MIT
License-File: LICENSE
Keywords: arviz,bayesian,dataframe,draws,mcmc,polars,tidybayes,visualisation
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Scientific/Engineering :: Information Analysis
Classifier: Topic :: Scientific/Engineering :: Mathematics
Classifier: Topic :: Scientific/Engineering :: Visualization
Requires-Python: >=3.11
Requires-Dist: arviz<1.0,>=0.23; python_version < '3.12'
Requires-Dist: arviz>=1.0; python_version >= '3.12'
Requires-Dist: numpy
Requires-Dist: polars>=0.20
Requires-Dist: pyarrow>=24.0.0
Requires-Dist: vegafusion-python-embed>=1.6
Requires-Dist: xarray
Provides-Extra: all
Requires-Dist: altair>=6.2.2; extra == 'all'
Requires-Dist: lets-plot; extra == 'all'
Requires-Dist: plotnine; extra == 'all'
Requires-Dist: seaborn; extra == 'all'
Requires-Dist: vegafusion-python-embed>=1.6; extra == 'all'
Requires-Dist: vegafusion>=2.0; extra == 'all'
Requires-Dist: vl-convert-python>=1.9.0; extra == 'all'
Provides-Extra: altair
Requires-Dist: altair>=6.2.2; extra == 'altair'
Requires-Dist: vegafusion-python-embed>=1.6; extra == 'altair'
Requires-Dist: vegafusion>=2.0; extra == 'altair'
Requires-Dist: vl-convert-python>=1.9.0; extra == 'altair'
Provides-Extra: dev
Requires-Dist: altair>=6.2.2; extra == 'dev'
Requires-Dist: great-docs>=0.14.0; extra == 'dev'
Requires-Dist: ipykernel; extra == 'dev'
Requires-Dist: mypy>=1.0; extra == 'dev'
Requires-Dist: pandas-stubs; extra == 'dev'
Requires-Dist: plotnine; extra == 'dev'
Requires-Dist: prek; extra == 'dev'
Requires-Dist: pymc>=6.0.1; (python_version >= '3.12') and extra == 'dev'
Requires-Dist: pytest>=8.0; extra == 'dev'
Requires-Dist: quarto>=0.1; extra == 'dev'
Requires-Dist: ruff>=0.4; extra == 'dev'
Requires-Dist: vegafusion-python-embed>=1.6; extra == 'dev'
Requires-Dist: vegafusion>=2.0.3; extra == 'dev'
Requires-Dist: vl-convert-python>=1.9.0; extra == 'dev'
Provides-Extra: letsplot
Requires-Dist: lets-plot; extra == 'letsplot'
Provides-Extra: plotnine
Requires-Dist: plotnine; extra == 'plotnine'
Requires-Dist: seaborn; extra == 'plotnine'
Description-Content-Type: text/markdown

<div align="center">
  <a href="https://github.com/drbenvincent/tidydraws"><img width="40%" src="https://raw.githubusercontent.com/drbenvincent/tidydraws/main/docs/assets/logo.jpg"></a>
</div>

----

<div align="center">

[![PyPI Version](https://img.shields.io/pypi/v/tidydraws)](https://pypi.org/project/tidydraws/) [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT) [![Python](https://img.shields.io/badge/python-3.11%20|%203.12%20|%203.13%20|%203.14-blue)](https://pypi.org/project/tidydraws/)

[![CI](https://github.com/drbenvincent/tidydraws/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/drbenvincent/tidydraws/actions/workflows/ci.yml) [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff) [![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit)](https://github.com/pre-commit/pre-commit)

[![GitHub Stars](https://img.shields.io/github/stars/drbenvincent/tidydraws?style=flat)](https://github.com/drbenvincent/tidydraws) [![Downloads](https://static.pepy.tech/badge/tidydraws)](https://pepy.tech/project/tidydraws) [![PyPI Downloads](https://img.shields.io/pypi/dm/tidydraws)](https://pypi.org/project/tidydraws/)
</div>

<!-- docs-start -->

# tidydraws

> A tidybayes-inspired data layer for declarative Bayesian visualisation in Python

`tidydraws` turns MCMC output (ArviZ) into tidy Polars frames that are ready to plot — one `.to_pandas()` away from any ggplot-like backend. It does no plotting itself. Three functions, three spaces:

| Function | Space | Plot archetype |
| --- | --- | --- |
| [`parameter_draws()`](https://drbenvincent.github.io/tidydraws/docs/examples/parameter_draws.html) | parameter | density, forest, scatter |
| [`prediction_draws()`](https://drbenvincent.github.io/tidydraws/docs/examples/prediction_draws.html) | prediction | ribbon + line, fit + data |
| [`compare_draws()`](https://drbenvincent.github.io/tidydraws/docs/examples/compare_draws.html) | comparison | prior vs posterior, intervals |

![tidydraws example](https://raw.githubusercontent.com/drbenvincent/tidydraws/main/docs/assets/index-plot.png)

## Install

With uv:
```bash
uv add tidydraws
```

With pip:
```bash
pip install tidydraws
```

If you want the latest functionality merged into main but not yet released, install directly from GitHub:

```bash
pip install git+https://github.com/drbenvincent/tidydraws.git
```

Or with uv:

```bash
uv add git+https://github.com/drbenvincent/tidydraws.git
```

## Why tidydraws?

Plotting MCMC output in Python means manually slicing xarray dimensions, iterating groups, and aligning coordinates — imperative, verbose, error-prone. R's [`tidybayes`](https://github.com/mjskay/tidybayes) solved this with a data layer that respects parameter space vs prediction space. `tidydraws` brings that to Python on Polars.

> **Backend-agnostic:** `tidydraws` returns Polars `DataFrame`s. Call `.to_pandas()` to bridge to lets-plot, plotnine, or any library that takes pandas. See the [examples](https://drbenvincent.github.io/tidydraws/docs/examples/parameter_draws.html) for both lets-plot and plotnine versions.

---

*Inspired by [tidybayes](https://github.com/mjskay/tidybayes) for R.*
