Metadata-Version: 2.1
Name: detroit
Version: 1.2.2
Summary: detroit is wrapper for Python of d3js and Observable Plot.
Author-email: Benjamin BOURBON <ben.bourbon06@gmail.com>
License: BSD 3-Clause License
        
        Copyright (c) 2023, Benjamin Bourbon
        
        Redistribution and use in source and binary forms, with or without
        modification, are permitted provided that the following conditions are met:
        
        1. Redistributions of source code must retain the above copyright notice, this
           list of conditions and the following disclaimer.
        
        2. Redistributions in binary form must reproduce the above copyright notice,
           this list of conditions and the following disclaimer in the documentation
           and/or other materials provided with the distribution.
        
        3. Neither the name of the copyright holder nor the names of its
           contributors may be used to endorse or promote products derived from
           this software without specific prior written permission.
        
        THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
        AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
        IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
        DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
        FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
        DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
        SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
        CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
        OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
        OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
        
Project-URL: Homepage, https://github.com/bourbonut/detroit
Project-URL: Repository, https://github.com/bourbonut/detroit
Project-URL: Documentation, https://detroit.readthedocs.io/en/latest/
Classifier: License :: OSI Approved :: BSD License
Classifier: Programming Language :: JavaScript
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Visualization
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: jinja2
Requires-Dist: markupsafe
Requires-Dist: playwright
Requires-Dist: quart
Provides-Extra: jupyter
Requires-Dist: notebook; extra == "jupyter"
Requires-Dist: nest_asyncio; extra == "jupyter"

<p align="center">
    <img style="border-radius:15px" src="https://raw.githubusercontent.com/bourbonut/detroit/main/docs/source/_static/logo.png"></img>
    <br />
    <a href="https://pypi.org/project/detroit/">
        <img src="https://img.shields.io/pypi/v/detroit.svg?style=flat&logo=pypi" alt="PyPI Latest Release">
    </a>
    <a href='https://detroit.readthedocs.io/en/latest/?badge=latest'>
        <img src='https://readthedocs.org/projects/detroit/badge/?version=latest' alt='Documentation Status' />
    </a>
    <a href="https://img.shields.io/badge/license-MIT-red.svg?style=flat">
        <img src="https://img.shields.io/badge/License-BSD%203--Clause-blue.svg" alt="BSD-3-Clause">
    </a>
</p>

detroit is wrapper for Python of [d3js](https://d3js.org/) and [Observable Plot](https://observablehq.com/plot/).

- [Documentation](https://detroit.readthedocs.io/en/latest/)

# Installation

```sh
pip install detroit
```

Then you will need to install a browser through the Python package `playwright`.
For the moment, only `chromium` is supported.

```sh
playwright install chromium
```

# Features

- Write as close as possible `d3` and `Plot` code
- Render one or multiple plots in your browser or in your jupyter notebook
- Customize style as you want
- Save them into `.svg`, `.png` or `.pdf`

# Quick Example


```py
import polars as pl
from sklearn.datasets import load_digits
from sklearn.decomposition import PCA
from sklearn.preprocessing import StandardScaler

from detroit import Plot, js, render, save

mnsit = load_digits()
scaler = StandardScaler()
X_scaled = scaler.fit_transform(mnsit.data)
pca = PCA(n_components=2)
components = pca.fit_transform(X_scaled)

# Prepare your data with Polars, Pandas or manually
df = pl.DataFrame(components, schema=["Component 1", "Component 2"])
df = df.insert_column(2, pl.Series("digit", mnsit.target))

plot = Plot.plot({
  "style": {"backgroundColor": "#161b22", "color": "#e6edf3"},
  "symbol": {"legend": js("true")},
  "color": {"scheme": "rainbow"},
  "marks": [
      Plot.dot(js("data"), {
          "x": "Component 1",
          "y": "Component 2",
          "stroke": "digit",
          "symbol": "digit"
      })
  ]
})

render(df, plot, style={"body": {"background": "#161b22", "color": "#e6edf3"}})
```

<p align="center">
    <img src="https://raw.githubusercontent.com/bourbonut/detroit/main/docs/source/figures/quick.png"></img>
</p>
