forked from napari/napari
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgrid_mode.py
More file actions
38 lines (29 loc) · 1.12 KB
/
Copy pathgrid_mode.py
File metadata and controls
38 lines (29 loc) · 1.12 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
"""
Grid mode
=========
Display layers in a grid using the `viewer.grid` API. When grid is enabled,
layers are automatically arranged - based on the stride, height, and width parameters -
in a grid of viewboxes linked to the main Camera and Dims. Viewer overlays such as
scale_bar can also be shown in a gridded manner.
.. tags:: visualization-basic
"""
from skimage import data
import napari
viewer = napari.Viewer()
layers = viewer.add_image(data.lily(), channel_axis=2)
viewer.grid.enabled = True
# a stride of 2 means that two consecutive layers are placed in each
# viewbox instead of just one
viewer.grid.stride = 2
# we leave width and height as -1, automatically resulting in a square grid
# setting the spacing to a value between 0 and 1 adds a padding between
# viewboxes relative to their sizes. Setting to a value greater than 1
# results in a padding of that exact number of pixels instead.
viewer.grid.spacing = 0.1
viewer.scale_bar.visible = True
viewer.scale_bar.box = True
# show scalebar in each grid instead of just once
viewer.scale_bar.gridded = True
viewer.fit_to_view()
if __name__ == '__main__':
napari.run()