Ways to prevent tooltips from colliding

I have two lines in a single plot and am using HoverTool with mode=‘vline’ so that tooltips show up for both lines at the same time. The problem is that sometimes the lines get very close to each other, so that the tooltips overlap, which is very unsightly. A simple solution would be to always have one tooltip appear on the left and one appear on the right. Is there a way to control where the tooltips appear? Or is there any other good practice to prevent colliding tooltips? Here is a code snippet:

hover = HoverTool(mode=‘vline’)
hover.tooltips = “”"

Date: @dates
Value1: @val1{,}
""" hover.renderers = [line1] plt.add_tools(hover)

hover = HoverTool(mode=‘vline’)
hover.tooltips = “”"

Date: @dates
Value2: @val2{,}
""" hover.renderers = [line2] plt.add_tools(hover)



The HoverTool has an attachment property mentioned here.https://docs.bokeh.org/en/latest/docs/reference/models/tools.html

It takes an enumerated value of type TooltipAttachment which is summarized here.https://docs.bokeh.org/en/latest/docs/reference/core/enums.html#bokeh.core.enums.TooltipAttachment

There are a variety implementations you can consider based on personal preference.

One option is to use separate hover tools with left/right attachments for the two lines or above/below attachments for the two lines (if you know something about their vertical relationships relative to one another).

Another option is to consolidate the information for both lines into a single tooltip. If that makes sense for your application, you could decide whether you want the tooltip to be anchored-to either of the existing lines or you could add a separate transparent (alpha=0.0) line for the tooltip that follows the midpoint of your two curves, rides along an axis, or any other curve that makes sense.

Very helpful, thanks!