Search code examples
pythonpandasbokeh

Format text alignment within Bokehs HoverTool/tooltips - Python


I have the hover function on in Pandas Bokehs.

How do I justify the text to the left hand side of the box rather than the right? See the attached image

This is my current code for my tooltips

tooltips=[('Time','@{Time}'), ('Propeller, Fx [kN]','@{Propeller, Fx [kN]}{1.1}')\
            ,('Engine RPM [rpm]','@{Engine RPM [rpm]}{1.1}')\
            ,('Fwd. Velocity, u [knots]', '@{Fwd. Velocity, u [knots]}{1.1}')]
p.add_tools(HoverTool(tooltips=tooltips))

Solution

  • The basic convenience auto-tooltip always and only ever formats as shown in the image. If you want something more sophisticated, you would use a custom tooltip, which allows you to supply a small HTML template to format things however you like.