Reputation: 45
my plot is showing ??? when I have space or special char on the column name. here is my code :
from bokeh.plotting import figure, show, ColumnDataSource
import pandas as pd
# prepare some data
xx = [1, 2, 3, 4, 5]
yy = [4, 5, 5, 7, 2]
df_xy = pd.DataFrame(list(zip(xx, yy)), columns=['name with space', 'y_y:y'])
#df_xy = pd.DataFrame(list(zip(xx, yy)), columns=['name', 'y'])
source = ColumnDataSource(df_xy)
pp = figure(y_range=(0, 10), sizing_mode="stretch_width", max_width=500, height=250,
tooltips="@name with space has the value @y_y:y")
# tooltips="@name has the value @y")
pp.circle(source.column_names[1], source.column_names[2], size=10, source=source)
pp.line(source.column_names[1], source.column_names[2], line_width=2, source=source)
# show the results
show(pp)
the df is like this
name with space y_y:y
0 1 4
1 2 5
2 3 5
3 4 7
4 5 2
when I change the column name with regular name (no space, no spcial char) it works.
how can I make it work ?
Upvotes: 3
Views: 718
Reputation: 143187
You can use "@{name with space}
and @{y_y:y}
tooltips="@{name with space} has the value @{y_y:y}"
BTW:
If you want to format then you can use another { }
ie. @{y_y:y}{0.00}
to get value with two digits after dot.
tooltips="@{name with space} has the value @{y_y:y}{0.00}"
Example from older version 1.0.4 shows more - i.e multiline tooltip and formatters
:
tools_hover_tooltip_formatting.py
Other information in the latest doc: basic-tooltips
Upvotes: 3