# 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)
Raw data
{
"_id": null,
"home_page": "https://gitlab.com/cerfacs/showy",
"name": "showy",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": "",
"keywords": "declarative visualization,matplotlib",
"author": "CoopTeam-CERFACS",
"author_email": "coop@cerfacs.com",
"download_url": "https://files.pythonhosted.org/packages/56/81/f254a5921274f8d48705aba77dde4ecb471f5d42085cc744225848130d8a/showy-0.1.5.tar.gz",
"platform": null,
"description": "\n# showy\n\n\n``showy`` is a helper for matplotlib subplots.\n\n\n\n## Usage\n\n\n``showy`` can be used in a script-like manner. \n\nLet's first define the layout:\n\n```python\nlayout = {\n \"title\": \"Example\",\n \"graphs\": [\n {\n \"curves\": [{\"var\": \"sine_10\"}],\n \"x_var\": \"time\",\n \"y_label\": \"Fifi [mol/m\u00b3/s]\",\n \"x_label\": \"Time [s]\",\n \"title\": \"Sinus of frequency *\"\n },\n {\n \"curves\": [{\"var\": \"sine_30\"}],\n \"x_var\": \"time\",\n \"y_label\": \"Riri [Hz]\",\n \"x_label\": \"Time [s]\",\n \"title\": \"Second graph\"\n },\n {\n \"curves\": [\n {\n \"var\": \"sine_100\",\n \"legend\": \"origin\",\n },\n {\n \"var\": \"sine_100p1\",\n \"legend\": \"shifted\",\n }\n ],\n \"x_var\": \"time\",\n \"y_label\": \"Loulou [cow/mug]\",\n \"x_label\": \"Time [s]\",\n \"title\": \"Third graphg\"\n }\n ],\n \"figure_structure\": [3, 1],\n \"figure_dpi\": 92.6\n}\n```\n\nNow, let's create dummy data:\n\n```python\nimport numpy as np\n\ndata = dict()\ndata[\"time\"] = np.linspace(0, 0.1, num=256)\n\ndata[\"sine_10\"] = np.cos(data[\"time\"] * 10 * 2 * np.pi)\ndata[\"sine_30\"] = np.cos(data[\"time\"] * 30 * 2 * np.pi)\ndata[\"sine_100\"] = np.cos(data[\"time\"] * 100 * 2 * np.pi)\ndata[\"sine_100p1\"] = 1. + np.cos(data[\"time\"] * 100 * 2 * np.pi)\n```\n\nFinally, we just have to display it:\n\n```python\nfrom showy import showy\n\nshowy(layout, data)\n```\n\n\n**Tip**: Define the layout in a ``yaml`` or ``json`` file in order to it across applications.\n\nIf you define it in a ``yaml`` file, then load it with (need to install [``pyyaml``](https://pypi.org/project/PyYAML/):\n\n```python\nimport yaml\n\nwith open(filename, 'r') as file:\n layout = yaml.load(file, Loader=yaml.SafeLoader)\n```\n\nIf you define it in a ``json`` file, then load it with:\n\n```python\nimport json\n\nwith open(filename, 'r') as file:\n layout = json.load(filename)\n\n```\n\n\n\n### Using wildcard `*`\n\nA 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_*``.\n\nThe example above reduces to:\n\n\n```python\nlayout = {\n \"title\": \"Example\",\n \"graphs\": [{\n \"curves\": [{\"var\": \"sine_*\"}],\n \"x_var\": \"time\",\n \"y_label\": \"Sine [mol/m\u00b3/s]\",\n \"x_label\": \"Time [s]\",\n \"title\": \"Sinus of frequency *\"\n }],\n \"figure_structure\": [3, 3],\n \"figure_dpi\": 92.6\n}\n```\n\n\n## json-schema standard\n\n``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)\n\n\n\n",
"bugtrack_url": null,
"license": "",
"summary": "Helper for matplotlib subplots.",
"version": "0.1.5",
"split_keywords": [
"declarative visualization",
"matplotlib"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "a0de56f43ec5ecc87584df0faf915f14f68c46fb7927a72d0069083be37f2680",
"md5": "fcd37772d4ea8e8789e14c71941de08e",
"sha256": "6c60c3fa7d7d1af31e18e76cabc2e24dd8dd44b7aa377d422494334d75af6277"
},
"downloads": -1,
"filename": "showy-0.1.5-py3-none-any.whl",
"has_sig": false,
"md5_digest": "fcd37772d4ea8e8789e14c71941de08e",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 7744,
"upload_time": "2023-03-10T12:35:40",
"upload_time_iso_8601": "2023-03-10T12:35:40.404178Z",
"url": "https://files.pythonhosted.org/packages/a0/de/56f43ec5ecc87584df0faf915f14f68c46fb7927a72d0069083be37f2680/showy-0.1.5-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "5681f254a5921274f8d48705aba77dde4ecb471f5d42085cc744225848130d8a",
"md5": "046466da6414b945a595621c929d4912",
"sha256": "aa0f7dbb9304ebf7bbd10c8f6db801ba1f4ff7cd722367ead07552e9bebbc724"
},
"downloads": -1,
"filename": "showy-0.1.5.tar.gz",
"has_sig": false,
"md5_digest": "046466da6414b945a595621c929d4912",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 8173,
"upload_time": "2023-03-10T12:35:42",
"upload_time_iso_8601": "2023-03-10T12:35:42.743839Z",
"url": "https://files.pythonhosted.org/packages/56/81/f254a5921274f8d48705aba77dde4ecb471f5d42085cc744225848130d8a/showy-0.1.5.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-03-10 12:35:42",
"github": false,
"gitlab": true,
"bitbucket": false,
"gitlab_user": "cerfacs",
"gitlab_project": "showy",
"lcname": "showy"
}