1
我有一个数据帧作为如何将标签添加到散景条形图?
df = pd.DataFrame(data = {'Country':'Spain','Japan','Brazil'],'Number':[10,20,30]})
我想绘制带标签的条形图(即“编号”的值)注释在顶部为每个条,并相应地进行。
from bokeh.charts import Bar, output_file,output_notebook, show
from bokeh.models import Label
p = Bar(df,'Country', values='Number',title="Analysis", color = "navy")
label = Label(x='Country', y='Number', text='Number', level='glyph',x_offset=5, y_offset=-5)
p.add_annotation(label)
output_notebook()
show(p)
但是我得到了一个错误,如ValueError: expected a value of type Real, got COuntry of type str
。
我该如何解决这个问题?