将图中的图例设置为散景中的列名称

Set the legend in a plot to have the name of a column in bokeh

下面是我的代码,如何让图例采用 rf.index[0] 中列的名称。 只需将 rf.index[0] 传递给图例即可创建类别图例,而不是列的实际名称。

p1.line(
    x = 'x',
    y = rf.index[0],
    source=source,
    legend = ???,
    color = 'black'

)

答案在这里!

legend = dict(value=rf.index[0])

来源

https://github.com/bokeh/bokeh/issues/5365