hello. I am in the process of creating an hbar. I tried to use tooltips so that the y value and the right value of the hbar come out when I hover over the graph, but as shown in the picture, type:??? value:??? is displayed, so I tried using hover, but it’s the same. If so, what should I do? The bokeh version is 3.1.0. Any help would be greatly appreciated.
Thank you for help me.
import pandas as pd
from bokeh.plotting import figure, output_file, show
from bokeh.models import ColumnDataSource, HoverTool, Title
from bokeh.palettes import Spectral4
import csv
with open('./lecturespace/2013data.csv') as f:
reader = csv.reader(f)
for row in reader:
if len(row) == 0 or row[0][0] == '#':
continue
else:
print(row)
type = []
value = []
with open('./lecturespace/2013data.csv') as f:
reader = csv.reader(f)
for column in reader:
if len(column) == 0 or column[0][0] == '#':
continue
else:
type.append(str(column[0]))
value.append(int(column[1]))
from bokeh.models import BasicTickFormatter
from bokeh.models import NumeralTickFormatter
xformatter = NumeralTickFormatter(format="0,0")
p=figure(y_range=type,title=Title(text="2013's data", align="center", text_font_size = "25px",text_font="Consolas",
text_font_style="bold"), height=400, width=800,tooltips=tooltips)
colors = {'출생아수': Spectral4[0], '사망자수': Spectral4[1], '생산가능인구(15-64)': Spectral4[2], '고령인구(65-)': Spectral4[3]}
color_list = [colors[t] for t in type]
p.xaxis.formatter = BasicTickFormatter(use_scientific=False)
p.xaxis.formatter = xformatter
hover = p.select(dict(type=HoverTool))
formatters={'@index1': 'type','@index2' : 'value'}
hover.tooltips = [('type', '@index1'), ('value', '@index2')]
p.hbar(y=type, right=value,height=0.5,color=color_list)
show(p)
This is my csv file data when I run print(row)
[‘출생아수’, ‘436500’]
[‘사망자수’, ‘266257’]
[‘생산가능인구(15-64)’, ‘370140’]
[‘고령인구(65-)’, ‘60230’]
beacuase of new user’s policy, There is one image.