A CLI application to plot data with Matplotlib.
| assets |
simplify pyplot hm example and split colorbar
|
|
| install.py | fix install script extension (sh -> py) | |
| LICENSE | add license (GPL v3) | |
| pyplot.py | refactor "fig, ax = ..." | |
| README.md | fix image path in README | |
| TODO.md | add another TODO with HUID | |
Pyplot: A CLI application to plot data with Matplotlib.
Caution
Pyplot requires the UV Python manager to work: install it here.
Note
all the scripts and snippets below are written in Nushell (0.107.0).
Tip
a TODO list for Pyplot is available in
TODO.md
installation
it is recommended to use the install.py script to install Pyplot locally.
pyplot plot
f_1: x \mapsto \sin(2 \pi x)
f_2: x \mapsto \cos(2 \pi x)
./pyplot.py plot ...[
-v ...(seq 0 100 | each { 50 * 3.14 * $in | math sin })
-v ...(seq 0 100 | each { 50 * 3.14 * $in | math cos })
--figsize 16 9
--dpi 100
]
pyplot imshow
let w = 15
let h = 10
seq 1 $h
| each {
seq 1 $w | each {
[(random int ..<256), (random int ..<256), (random int ..<256), 255]
}
}
| to json
| ./pyplot.py imshow $in ...[
--figsize $w $h
--dpi 50
]
pyplot hm
f: (x, y) \mapsto 30 \sin (50 x) - 50 y \cos (50 y)
x \in [0, 1]
y \in [0, 1]
let w = 160
let h = 100
let xs = seq 0 (1 / $w) 1.0
let ys = seq 0 (1 / $h) 1.0
let hm = $ys | each { |y| $xs | each { |x| 30 * ($x * 50 | math sin) - $y * 50 * ($y * 50 | math cos) } } | reverse
./pyplot.py hm ($hm | to json) ...[
--cmap viridis
--xticks ...($xs | enumerate | window --stride 10 10 | each { first } | each { $"( $in.index):($in.item | math round --precision 2)" })
--yticks ...($ys | enumerate | window --stride 10 10 | each { first } | reverse | each { $"($h - $in.index):($in.item | math round --precision 2)" })
--cbardir "horizontal"
--figsize 14 9
--dpi 100
]
./pyplot.py hm "" ...[
--cmap viridis
--cbar
--cbardir "horizontal"
--cbarmin ($hm | flatten | math min)
--cbarmax ($hm | flatten | math max)
--figsize 10 0.5
--dpi 100
]