-
Notifications
You must be signed in to change notification settings - Fork 64
Expand file tree
/
Copy pathspecify_integers.py
More file actions
50 lines (36 loc) · 1.07 KB
/
specify_integers.py
File metadata and controls
50 lines (36 loc) · 1.07 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
"""
Specify IDs with integers
=========================
Specify controllers to sync subplots using integer IDs
"""
# test_example = false
# sphinx_gallery_pygfx_docs = 'screenshot'
import numpy as np
import fastplotlib as fpl
xs = np.linspace(0, 2 * np.pi, 100)
sine = np.sin(xs)
cosine = np.cos(xs)
# controller IDs
# one controller is created for each unique ID
# if the IDs are the same, those subplots will be synced
ids = [
[0, 1],
[2, 0],
]
figure = fpl.Figure(
shape=(2, 2),
controller_ids=ids,
size=(700, 560),
)
for subplot, controller_id in zip(figure, np.asarray(ids).ravel()):
subplot.title = f"contr. id: {controller_id}"
figure[0, 0].add_line(np.column_stack([xs, sine]))
figure[0, 1].add_line(np.random.rand(100))
figure[1, 0].add_line(np.random.rand(100))
figure[1, 1].add_line(np.column_stack([xs, cosine]))
figure.show(maintain_aspect=False)
# NOTE: fpl.loop.run() should not be used for interactive sessions
# See the "JupyterLab and IPython" section in the user guide
if __name__ == "__main__":
print(__doc__)
fpl.loop.run()