Metadata-Version: 2.4
Name: showy
Version: 1.0.0
Summary: Helper for matplotlib subplots.
Author-email: CoopTeam-CERFACS <coop@cerfacs.fr>
License: MIT License
        
        Copyright (c) 2021 Cerfacs/COOP Team
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://gitlab.com/cerfacs/showy
Project-URL: Documentation, https://showy.readthedocs.io/en/latest/
Project-URL: Issues, https://gitlab.com/cerfacs/showy/-/issues
Project-URL: Changelog, https://gitlab.com/cerfacs/showy/-/blob/master/CHANGELOG.md
Keywords: declarative visualization,matplotlib
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: Visualization
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: matplotlib
Requires-Dist: pyyaml
Requires-Dist: jsonschema
Provides-Extra: tests
Requires-Dist: pytest; extra == "tests"
Requires-Dist: pytest-coverage; extra == "tests"
Requires-Dist: pytest-allclose; extra == "tests"
Dynamic: license-file


# showy


``showy`` is a helper for matplotlib subplots.



## Usage


``showy`` can be used in a script-like manner. 

Let's first define the layout:

```python
layout = {
    "title": "Example",
    "graphs": [
        {
            "curves": [{"var": "sine_10"}],
            "x_var": "time",
            "y_label": "Fifi [mol/m³/s]",
            "x_label": "Time [s]",
            "title": "Sinus of frequency *"
        },
        {
            "curves": [{"var": "sine_30"}],
            "x_var": "time",
            "y_label": "Riri [Hz]",
            "x_label": "Time [s]",
            "title": "Second graph"
        },
        {
            "curves": [
                {
                    "var": "sine_100",
                    "legend": "origin",
                },
                {
                    "var": "sine_100p1",
                    "legend": "shifted",
                }
            ],
            "x_var": "time",
            "y_label": "Loulou [cow/mug]",
            "x_label": "Time [s]",
            "title": "Third graphg"
        }
    ],
    "figure_structure": [3, 1],
    "figure_dpi": 92.6
}
```

Now, let's create dummy data:

```python
import numpy as np

data = dict()
data["time"] = np.linspace(0, 0.1, num=256)

data["sine_10"] = np.cos(data["time"] * 10 * 2 * np.pi)
data["sine_30"] = np.cos(data["time"] * 30 * 2 * np.pi)
data["sine_100"] = np.cos(data["time"] * 100 * 2 * np.pi)
data["sine_100p1"] = 1. + np.cos(data["time"] * 100 * 2 * np.pi)
```

Finally, we just have to display it:

```python
from showy import showy

showy(layout, data)
```


**Tip**: Define the layout in a ``yaml`` or ``json`` file in order to it across applications.

If you define it in a ``yaml`` file, then load it with (need to install [``pyyaml``](https://pypi.org/project/PyYAML/):

```python
import yaml

with open(filename, 'r') as file:
  layout = yaml.load(file, Loader=yaml.SafeLoader)
```

If you define it in a ``json`` file, then load it with:

```python
import json

with open(filename, 'r') as file:
  layout = json.load(filename)

```



### Using wildcard `*`

A neat feature of ``showy`` is the wild card usage to simplify layout creation. For example, if you have 3 variables called ``var_1``, ``var_2``, ``var_3``, you only need to define the graph layout for a variable ``var_*``.

The example above reduces to:


```python
layout = {
    "title": "Example",
    "graphs": [{
        "curves": [{"var": "sine_*"}],
        "x_var": "time",
        "y_label": "Sine [mol/m³/s]",
        "x_label": "Time [s]",
        "title": "Sinus of frequency *"
    }],
    "figure_structure": [3, 3],
    "figure_dpi": 92.6
}
```


## json-schema standard

``showy`` is based on a json-schema standard defined [here](https://gitlab.com/cerfacs/showy/raw/master/src/showy/schema.yaml). Check [this](https://cerfacs.fr/coop/json-schema-for-sci-apps) out to learn more about the usage of the json-schema standard. (For your daily usage of ``showy`` you just need to ensure your layout respects the schema)



