@@ -65,7 +65,20 @@ def draw(self) -> None:
65
65
self .axes .set_xlabel (x_axis_name )
66
66
self .axes .set_ylabel (y_axis_name )
67
67
68
- def _get_data (self ) -> Tuple [np .ndarray , str , str ]:
68
+ def _get_data (self ) -> Tuple [List [np .ndarray ], str , str ]:
69
+ """Get the plot data.
70
+
71
+ This must be implemented on the subclass.
72
+
73
+ Returns
74
+ -------
75
+ data : np.ndarray
76
+ The list containing the scatter plot data.
77
+ x_axis_name : str
78
+ The title to display on the x axis
79
+ y_axis_name: str
80
+ The title to display on the y axis
81
+ """
69
82
raise NotImplementedError
70
83
71
84
@@ -91,7 +104,18 @@ def __init__(
91
104
histogram_for_large_data = histogram_for_large_data ,
92
105
)
93
106
94
- def _get_data (self ) -> Tuple [np .ndarray , str , str ]:
107
+ def _get_data (self ) -> Tuple [List [np .ndarray ], str , str ]:
108
+ """Get the plot data.
109
+
110
+ Returns
111
+ -------
112
+ data : List[np.ndarray]
113
+ List contains the in view slice of X and Y axis images.
114
+ x_axis_name : str
115
+ The title to display on the x axis
116
+ y_axis_name: str
117
+ The title to display on the y axis
118
+ """
95
119
data = [layer .data [self .current_z ] for layer in self .layers ]
96
120
x_axis_name = self .layers [0 ].name
97
121
y_axis_name = self .layers [1 ].name
@@ -152,12 +176,39 @@ def _set_axis_keys(self, x_axis_key: str, y_axis_key: str):
152
176
self ._draw ()
153
177
154
178
def _get_valid_axis_keys (self , combo_widget = None ) -> List [str ]:
155
- if len (self .layers ) == 0 :
179
+ """Get the valid axis keys from the layer FeatureTable.
180
+
181
+ Returns
182
+ -------
183
+ axis_keys : List[str]
184
+ The valid axis keys in the FeatureTable. If the table is empty
185
+ or there isn't a table, returns an empty list.
186
+ """
187
+ if len (self .layers ) == 0 or not (hasattr (self .layers [0 ], "features" )):
156
188
return []
157
189
else :
158
190
return self .layers [0 ].features .keys ()
159
191
160
- def _get_data (self ) -> Tuple [np .ndarray , str , str ]:
192
+ def _get_data (self ) -> Tuple [List [np .ndarray ], str , str ]:
193
+ """Get the plot data.
194
+
195
+ Returns
196
+ -------
197
+ data : List[np.ndarray]
198
+ List contains X and Y columns from the FeatureTable. Returns
199
+ an empty array if nothing to plot.
200
+ x_axis_name : str
201
+ The title to display on the x axis. Returns
202
+ an empty string if nothing to plot.
203
+ y_axis_name: str
204
+ The title to display on the y axis. Returns
205
+ an empty string if nothing to plot.
206
+ """
207
+ if not hasattr (self .layers [0 ], "features" ):
208
+ # if the selected layer doesn't have a featuretable,
209
+ # skip draw
210
+ return np .array ([]), "" , ""
211
+
161
212
feature_table = self .layers [0 ].features
162
213
163
214
if (
@@ -169,7 +220,7 @@ def _get_data(self) -> Tuple[np.ndarray, str, str]:
169
220
170
221
data_x = feature_table [self .x_axis_key ]
171
222
data_y = feature_table [self .y_axis_key ]
172
- data = np . stack (( data_x , data_y ))
223
+ data = [ data_x , data_y ]
173
224
174
225
x_axis_name = self .x_axis_key .replace ("_" , " " )
175
226
y_axis_name = self .y_axis_key .replace ("_" , " " )
0 commit comments