Helper for matplotlib subplots.
Project description
showy
showy is a helper for matplotlib 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 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:
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
}
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)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file showy-1.0.0.tar.gz.
File metadata
- Download URL: showy-1.0.0.tar.gz
- Upload date:
- Size: 10.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4cde00a34e6fcd038717c0d764c73e7ae9f00ff245d7430d9a341a2edf2aa5d1
|
|
| MD5 |
39c0c1561f8b4d75ab62a4e5852275e6
|
|
| BLAKE2b-256 |
d02e6db928f708239b8acff838c8e862d5dc2bc6525b5357a2a8f8f44ab21a7c
|
File details
Details for the file showy-1.0.0-py3-none-any.whl.
File metadata
- Download URL: showy-1.0.0-py3-none-any.whl
- Upload date:
- Size: 8.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
03b08842bd6ed9d515e94a272f735856059376cfb54e6c80165acf0d3d006300
|
|
| MD5 |
97afd56a297e739c8a9f6f9dfb2222d9
|
|
| BLAKE2b-256 |
0b12dfc6bd18030e340d41db2b872b5882522791b8a1b193d287301c34e29f6f
|