Can Bokeh’s Hovertool
print data if the Column name is non-English in a ColumnDataSource
?
Here’s a quick example:
import pandas as pd
from bokeh.models.sources import ColumnDataSource
from bokeh.plotting import figure, show
from bokeh.models.tools import HoverTool
# Set up the data
non_english_col_name = '名前'
df = pd.DataFrame({
non_english_col_name: ['a','b'],
'x': [1,2],
'y': [0,3]
})
source = ColumnDataSource(df)
# Create the glyphs
p = figure()
scatter = p.scatter(source = source)
# Create the Hovertool
hover_tool = HoverTool(renderers=[scatter],
tooltips=[('Name', f'@{non_english_col_name}'),
('x','@x'),
('y','@y')]
)
p.add_tools(hover_tool)
show(p)
Both x
and y
show up fine in the Hover, but the non-English column name (non_english_col_name
) doesn’t display the data and treats it as a string literal. Is there a workaround for this other than re-naming the column name to an English name?