我大致按照Bokeh 文檔中的 texas.py 示例創建了一張地圖。我正在嘗試在地圖上添加一個具有自己鼠標懸停行為的點。我添加了以下字形:bc_glyph = Circle(x=barclays_x, y=barclays_y, size=10, line_color="black", fill_color="silver", line_width=1)我嘗試使用以下方法創建自定義 HoverTool 行為:bc_ht = HoverTool(renderers=['bc_glyph'], tooltips=['Barclays Stadium'])然后我打了電話plot.add_glyph(bc_glyph)。運行我的腳本時,我得到以下輸出:ValueError: expected an element of either Auto or List(Instance(Renderer)), got ['bc_glyph']錯誤消息的快速谷歌導致Bryan 幫助另一個用戶解決類似問題,所以我重寫如下:plot_add = plot.add_glyph(bc_glyph)
bc_ht = HoverTool(renderers=['plot_add'], tooltips=['Barclays Stadium'])但是,這會返回相同的錯誤:ValueError: expected an element of either Auto or List(Instance(Renderer)), got ['plot_add']我知道我向 提供了錯誤的輸入renderers,但我不確定如何更正。任何幫助表示贊賞。
1 回答

蕭十郎
TA貢獻1815條經驗 獲得超13個贊
您仍在傳遞一個字符串, 'plot_add', 作為值。您需要傳遞實際變量:
bc_ht = HoverTool(renderers=[plot_add], # no quote around plot_add
tooltips=['Barclays Stadium'])
添加回答
舉報
0/150
提交
取消