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
File details
Details for the file showy-0.1.1.tar.gz
.
File metadata
- Download URL: showy-0.1.1.tar.gz
- Upload date:
- Size: 7.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.7.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c5b58ecead371b93367142a033b2f7d8bb2e0326f23cd047332b137ef615f35a |
|
MD5 | 5c1dbe07bcde0777d43154e35c13afa2 |
|
BLAKE2b-256 | ea8336bf5aaaf4396b921f47a3cc5d7b722a3e3c059a43757fadfc4e858a15de |
File details
Details for the file showy-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: showy-0.1.1-py3-none-any.whl
- Upload date:
- Size: 7.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.7.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 60f6f23801adee75be258cf659b9ae23de66c045f08a96b6a357b94f3e0ec1e8 |
|
MD5 | 226331e39953cf452066bd00b6e403b0 |
|
BLAKE2b-256 | 57ffef029300751eae10eb8b53ddaa4ab94a7fd84cceb5be44c53ef0fe6f6d49 |