【发布时间】:2018-02-15 10:39:40
【问题描述】:
在文档中的示例中
from bokeh.io import show
from bokeh.models import ColumnDataSource
from bokeh.palettes import RdBu3
from bokeh.plotting import figure
c1 = RdBu3[2] # red
c2 = RdBu3[0] # blue
source = ColumnDataSource(dict(
x=[1, 2, 3, 4, 5, 6],
y=[2, 1, 2, 1, 2, 1],
color=[c1, c2, c1, c2, c1, c2],
label=['hi', 'lo', 'hi', 'lo', 'hi', 'lo']
))
p = figure(x_range=(0, 7), y_range=(0, 3), plot_height=300, tools='save')
# Note legend field matches the column in `source`
p.circle( x='x', y='y', radius=0.5, color='color', legend='label', source=source)
show(p)
有没有办法将图例中项目的顺序更改为 ('lo', 'hi') 而不是 ('hi', 'lo') 而不重新排序所有原始数组中的项目?
【问题讨论】:
-
我尝试按照文档中的建议检查
p.legend[0].items,但那里只有一项。 -
我想你可以找到为什么只有一个图例项here的答案。
标签: python plot legend bokeh legend-properties