1
0
Fork
You've already forked pyplot
0
A CLI application to plot data with Matplotlib.
Python 100%
2026年01月07日 19:03:07 +01:00
assets simplify pyplot hm example and split colorbar 2026年01月07日 19:01:56 +01:00
install.py fix install script extension (sh -> py) 2026年01月07日 18:49:41 +01:00
LICENSE add license (GPL v3) 2026年01月02日 14:21:04 +01:00
pyplot.py refactor "fig, ax = ..." 2026年01月07日 18:54:16 +01:00
README.md fix image path in README 2026年01月07日 19:03:07 +01:00
TODO.md add another TODO with HUID 2026年01月02日 18:59:05 +01:00

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
]

assets/plot-sin-cos.png

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
 ]

assets/imshow-random.png

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
]

assets/hm-xsin-ycos.png assets/hm-xsin-ycos_bar.png