@@ -169,27 +169,35 @@ def optical_traces(self, meta=None, shared_legend=True, legendgroup=None,
169169 if shared_legend and legendgroup is None :
170170 legendgroup = 'group_' + str (time .time ())
171171
172+ # Add a hovertext to the optical detectors
173+ hovertexts = [f'PD ID: { i } ' for i in range (len (positions ))]
174+ if color is not None and not np .isscalar (color ):
175+ hovertexts = [f'{ ht } <br>PE: { c :.3f} ' for ht , c in zip (hovertexts , color )]
176+
172177 # Draw each of the optical detectors
173178 traces = []
174179 for i , shape in enumerate (self .geo .optical .shape ):
175180 # Restrict the positions to those of this shape, if needed
176181 if shape_ids is None :
177182 pos = positions
178183 col = color
184+ ht = hovertexts
179185 else :
180186 index = np .where (np .asarray (shape_ids ) == i )[0 ]
181187 pos = positions [index ]
182188 if color is not None and not np .isscalar (color ):
183189 col = color [index ]
184190 else :
185191 col = color
192+ ht = [hovertexts [i ] for i in index ]
186193
187194 # If zero-supression is requested, only draw the optical detectors
188195 # which record a non-zero signal
189196 if zero_supress and color is not None and not np .isscalar (color ):
190197 index = np .where (np .asarray (col ) != 0 )[0 ]
191198 pos = pos [index ]
192199 col = col [index ]
200+ ht = [ht [i ] for i in index ]
193201
194202 # Determine wheter to show legends or not
195203 showlegend = not shared_legend or i == 0
@@ -204,7 +212,7 @@ def optical_traces(self, meta=None, shared_legend=True, legendgroup=None,
204212 traces += box_traces (
205213 lower , upper , shared_legend = shared_legend , name = name ,
206214 color = col , cmin = cmin , cmax = cmax , draw_faces = True ,
207- legendgroup = legendgroup , showlegend = showlegend , ** kwargs )
215+ hovertext = ht , legendgroup = legendgroup , showlegend = showlegend , ** kwargs )
208216
209217 else :
210218 # Convert the optical detector dimensions to a covariance matrix
@@ -214,7 +222,7 @@ def optical_traces(self, meta=None, shared_legend=True, legendgroup=None,
214222 traces += ellipsoid_traces (
215223 pos , covmat , shared_legend = shared_legend , name = name ,
216224 color = col , cmin = cmin , cmax = cmax ,
217- legendgroup = legendgroup , showlegend = showlegend , ** kwargs )
225+ hovertext = ht , legendgroup = legendgroup , showlegend = showlegend , ** kwargs )
218226
219227 return traces
220228
0 commit comments