如何在Span中将Span添加到图例中?

时间:2020-03-24 10:22:04

标签: bokeh legend

所以我创建了一个包含一些线和一个跨度(或多个跨度)的图形。

f = figure()
f.line(x, y1, legend_label='1st set')
f.line(x, y2, legend_label='2st set')
vl = Span(location=x_point,
          dimension='height',
          line_dash='dotdash', line_color="black", line_alpha=0.7)
f.add_layout(vl)

我想在该图的默认图例中添加跨度条目。

1 个答案:

答案 0 :(得分:2)

默认的Legend仅适用于字形渲染器,因此您无法直接将Span添加到图例。

但是您可以创建一个不带数据且具有与跨度相同参数的字形:

f.line([], [], legend_label='span'
       line_dash='dotdash', line_color="black", line_alpha=0.7)