-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcolormaps.py
More file actions
71 lines (66 loc) · 2.08 KB
/
colormaps.py
File metadata and controls
71 lines (66 loc) · 2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import tyro
import numpy as np
import matthewplotlib as mp
import hilbert
def main(save: str | None = None):
"""Colormap gallery with continuous and discrete colormaps."""
coords = hilbert.decode(
hilberts=np.arange(256),
num_dims=2,
num_bits=4,
)
im_continuous = np.zeros((16,16), dtype=float)
im_continuous[coords[:,0], coords[:,1]] = np.linspace(0.0, 1.0, 256)
im_discrete16 = np.zeros((16, 16), dtype=int)
im_discrete16[coords[:,0], coords[:,1]] = np.arange(256) // 16
im_discrete10 = np.zeros((16, 16), dtype=int)
im_discrete10[coords[:,0], coords[:,1]] = np.arange(256) // 25.6
plot = mp.vstack(
mp.text("test images:"),
mp.hstack(
mp.border(
mp.image(im_continuous),
title="linspace(0,1,256",
),
mp.border(
mp.image(im_discrete16 / 16),
title="arange(256)/16",
),
mp.border(
mp.image(im_discrete10 / 10),
title="arange(256)/25.6",
)
),
mp.text("continuous colormaps:"),
mp.wrap(*[
mp.border(
mp.image(im_continuous, colormap=c),
title=c.__name__,
)
for c in [
mp.reds, mp.greens, mp.blues, mp.rainbow,
mp.yellows, mp.magentas, mp.cyans, mp.cyber,
mp.magma, mp.inferno, mp.plasma, mp.viridis,
mp.divreds, mp.divgreens, mp.divblues,
]
], cols=4),
mp.text("discrete colormaps:"),
mp.wrap(*[
mp.border(
mp.image(im_discrete16, colormap=c),
title=c.__name__,
)
for c in [ mp.sweetie16, mp.pico8 ]
], *[
mp.border(
mp.image(im_discrete10, colormap=c),
title=c.__name__,
)
for c in [ mp.tableau, mp.nouveau ]
], cols=4),
)
print(plot)
if save:
plot.saveimg(save)
if __name__ == "__main__":
tyro.cli(main)