forked from napari/napari
-
Notifications
You must be signed in to change notification settings - Fork 0
/
scale_bar.py
42 lines (31 loc) · 968 Bytes
/
scale_bar.py
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
"""
Scale bar
=========
Display a 3D volume and the scale bar
.. tags:: experimental
"""
from skimage import data
import napari
cells = data.cells3d()
viewer = napari.Viewer(ndisplay=3)
viewer.add_image(
cells,
name=('membrane', 'nuclei'),
channel_axis=1,
scale=(0.29, 0.26, 0.26),
)
viewer.scale_bar.visible = True
# Text options
viewer.scale_bar.unit = 'um' # set to None to diplay no unit
viewer.scale_bar.length = 23 # length, in units, of the scale bar
viewer.scale_bar.font_size = 20 # default is 10
# Text color
viewer.scale_bar.colored = True # default value is False
viewer.scale_bar.color = 'yellow' # default value is magenta: (1,0,1,1)
# Background box
viewer.scale_bar.box = True # add background box, default is False
viewer.scale_bar.box_color = (0, 1, 1, 0.2) # cyan with alpha=0.2
# Scale bar position
viewer.scale_bar.position = 'bottom_left' # default is 'bottom_right'
if __name__ == '__main__':
napari.run()