My tooltips on my plot are much too large and overflow the plot, as the strings they display are long. I have been browsing around the source (and a bit of the javascript), but haven't found anywhere that might let me set the font without spinning my own HTML or JavaScript (i.e. via some Python object). I've also tried naively adding <br>
and \n
characters into the tooltip string, but that didn't work.
How can I change my tooltip fonts (or possibly other relevant attributes) easily?
Update: I've tried setting the font small, but am still unable to get newlines in the tooltip. Here is my tooltip code:
hover.tooltips = """
y: $y <br>
date: @dates <br>
items: <br><font face="Arial" size="1">@items</font>
"""
The issue is, each item from the items
source is a variable length list, and I wish to separate each entry in the list by a newline rendered in the tooltip
You can use a custom tooltip, which should let you do what you need.
At the moment, you've probably got something like:
hover.tooltips = [
("index", "$index"),
("foo", "@foo"),
("bar", "@bar"),
]
Try:
hover.tooltips = """
The index of my data is: $index <br>
My foo property is bold <strong>@foo</strong>
I could use a custom font <font face="Arial" size="3">@bar </font>
"""
You can see examples in the docs link above and in a couple of examples that are in the bokeh repo:
https://github.com/bokeh/bokeh/blob/master/examples/interactions/us_marriages_divorces/us_marriages_divorces_interactive.py#L64
https://github.com/bokeh/bokeh/blob/master/examples/glyphs/sprint.py#L90
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With