@@ -267,18 +267,6 @@ def selectable_axes_plot(
267267 ** kwargs ,
268268 )
269269
270- if tools is None :
271- base_tooltips = [("File:" , "@filename" ), (x_axis_label , "$x{0.00}" )]
272-
273- if "intensity" in y_label .lower ():
274- original_col = f"{ y_label } _original"
275- base_tooltips .append ((y_axis_label , f"@{{{ original_col } }}{{0.00}}" ))
276- else :
277- base_tooltips .append ((y_axis_label , "$y{0.00}" ))
278-
279- coordinate_hover = HoverTool (tooltips = base_tooltips , mode = "mouse" )
280- p .add_tools (coordinate_hover )
281-
282270 p .toolbar .logo = "grey"
283271
284272 if tools :
@@ -312,6 +300,7 @@ def selectable_axes_plot(
312300 labels = [shrink_label (label ) for label in original_labels ]
313301
314302 plot_columns = []
303+ hover_tools = []
315304
316305 for ind , df_ in enumerate (df ):
317306 if skip_plot :
@@ -330,6 +319,17 @@ def selectable_axes_plot(
330319
331320 source = ColumnDataSource (df_with_filename )
332321
322+ current_tooltips = [("File:" , "@filename" ), (x_axis_label , "$x{0.00}" )]
323+
324+ if "intensity" in y_label .lower ():
325+ original_col = f"{ y_label } _original"
326+ if original_col in source .data :
327+ current_tooltips .append ((y_axis_label , f"@{{{ original_col } }}{{0.00}}" ))
328+ else :
329+ current_tooltips .append ((y_axis_label , f"@{{{ y_default } }}" ))
330+ else :
331+ current_tooltips .append ((y_axis_label , f"@{{{ y_default } }}{{0.00}}" ))
332+
333333 if color_options :
334334 color = {"field" : color_options [0 ], "transform" : color_mapper }
335335 line_color = "black"
@@ -381,6 +381,14 @@ def selectable_axes_plot(
381381 else None
382382 )
383383
384+ line_hover = None
385+ if lines :
386+ line_hover = HoverTool (
387+ tooltips = current_tooltips , mode = "mouse" , renderers = [lines ], line_policy = "nearest"
388+ )
389+ p .add_tools (line_hover )
390+ hover_tools .append (line_hover )
391+
384392 if y_aux :
385393 for y in y_aux :
386394 aux_lines = ( # noqa
@@ -403,7 +411,7 @@ def selectable_axes_plot(
403411 line1 = lines ,
404412 source = source ,
405413 xaxis = p .xaxis [0 ],
406- hover_tool = coordinate_hover ,
414+ hover_tool = line_hover ,
407415 ),
408416 code = SELECTABLE_CALLBACK_x ,
409417 )
@@ -416,7 +424,7 @@ def selectable_axes_plot(
416424 line1 = lines ,
417425 source = source ,
418426 yaxis = p .yaxis [0 ],
419- hover_tool = coordinate_hover ,
427+ hover_tool = line_hover ,
420428 ),
421429 code = SELECTABLE_CALLBACK_y ,
422430 )
0 commit comments