11
11
12
12
13
13
class ScatterBaseWidget (NapariMPLWidget ):
14
+ # opacity value for the markers
15
+ _marker_alpha = 0.5
16
+
17
+ # flag set to True if histogram should be used
18
+ # for plotting large points
19
+ _histogram_for_large_data = True
20
+
21
+ # if the number of points is greater than this value,
22
+ # the scatter is plotted as a 2dhist
23
+ _threshold_to_switch_to_histogram = 500
24
+
14
25
def __init__ (
15
26
self ,
16
27
napari_viewer : napari .viewer .Viewer ,
17
- marker_alpha : float = 0.5 ,
18
- histogram_for_large_data : bool = True ,
19
28
):
20
29
super ().__init__ (napari_viewer )
21
30
22
- # flag set to True if histogram should be used
23
- # for plotting large points
24
- self .histogram_for_large_data = histogram_for_large_data
25
-
26
- # set plotting visualization attributes
27
- self ._marker_alpha = 0.5
28
-
29
31
self .axes = self .canvas .figure .subplots ()
30
32
self .update_layers (None )
31
33
32
- @property
33
- def marker_alpha (self ) -> float :
34
- """Alpha (opacity) for the scatter markers"""
35
- return self ._marker_alpha
36
-
37
- @marker_alpha .setter
38
- def marker_alpha (self , alpha : float ):
39
- self ._marker_alpha = alpha
40
- self ._draw ()
41
-
42
34
def clear (self ) -> None :
43
35
self .axes .clear ()
44
36
@@ -52,15 +44,15 @@ def draw(self) -> None:
52
44
# don't plot if there isn't data
53
45
return
54
46
55
- if self .histogram_for_large_data and (data [0 ].size > 500 ):
47
+ if self ._histogram_for_large_data and (data [0 ].size > 500 ):
56
48
self .axes .hist2d (
57
49
data [0 ].ravel (),
58
50
data [1 ].ravel (),
59
51
bins = 100 ,
60
52
norm = mcolor .LogNorm (),
61
53
)
62
54
else :
63
- self .axes .scatter (data [0 ], data [1 ], alpha = self .marker_alpha )
55
+ self .axes .scatter (data [0 ], data [1 ], alpha = self ._marker_alpha )
64
56
65
57
self .axes .set_xlabel (x_axis_name )
66
58
self .axes .set_ylabel (y_axis_name )
@@ -95,13 +87,9 @@ class ScatterWidget(ScatterBaseWidget):
95
87
def __init__ (
96
88
self ,
97
89
napari_viewer : napari .viewer .Viewer ,
98
- marker_alpha : float = 0.5 ,
99
- histogram_for_large_data : bool = True ,
100
90
):
101
91
super ().__init__ (
102
92
napari_viewer ,
103
- marker_alpha = marker_alpha ,
104
- histogram_for_large_data = histogram_for_large_data ,
105
93
)
106
94
107
95
def _get_data (self ) -> Tuple [List [np .ndarray ], str , str ]:
@@ -129,15 +117,11 @@ class FeaturesScatterWidget(ScatterBaseWidget):
129
117
def __init__ (
130
118
self ,
131
119
napari_viewer : napari .viewer .Viewer ,
132
- marker_alpha : float = 0.5 ,
133
- histogram_for_large_data : bool = True ,
134
120
key_selection_gui : bool = True ,
135
121
):
136
122
self ._key_selection_widget = None
137
123
super ().__init__ (
138
124
napari_viewer ,
139
- marker_alpha = marker_alpha ,
140
- histogram_for_large_data = histogram_for_large_data ,
141
125
)
142
126
143
127
if key_selection_gui is True :
0 commit comments