showy
showy is a helper for matplotlib and plotly subplots.
Usage
showy can be used in a script-like manner.
Let's first define the layout:
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:
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:
from showy import showy
showy(layout, data)
[!TIP] Define the layout in a
yamlorjsonfile in order to use it across applications.
If you define it in a yaml file, then load it with (need to install pyyaml:
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:
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:
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
}
Using Plotly
Showy supports Matplotlib and Plotly to display your graphs. Default is set to Matplotlib. To use Plotly, add backend="plotly" when calling showy:
from showy import showy
showy(layout, data, backend="plotly")
json-schema standard
showy is based on a json-schema standard defined here. Check this 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)
Metadata
Release files for showy 1.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| showy-1.1.2.tar.gz | 15.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| showy-1.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 30.1 kB
Release files / showy-1.1.2.tar.gz
| Download URL | showy-1.1.2.tar.gz |
|---|---|
| Size | 15.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a17adf87257df93abcb16f244f62c7ae44c4d726865c27294a7d2cdf46e79c69
|
|
BLAKE2b-256 checksum How to use checksums |
4ec00ec884de1960fcfc72b045b79efb216a714cbe1608aaa7ae7b06e035c3e3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.9
|
Release files / showy-1.1.2-py3-none-any.whl
| Download URL | showy-1.1.2-py3-none-any.whl |
|---|---|
| Size | 15.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b2825e8ddecce55ca088e97dd8bcfccdd896aa32696760d5fc731831aec5649c
|
|
BLAKE2b-256 checksum How to use checksums |
ee147db12a5b76c0cb17a3bead8ee3ff7b4a024af03e4a4b7daea44b9267cc01
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.9
|