一个轴上的多级(分组)标签,具有自动布局

Multi-level (grouped) labels on one axis with automatic layout

是否可以在散景中的一个轴上设置多个级别的标签?也就是说,对于像

这样的数据源
TheBars | ThFoos | TheValues
--------|--------|----------
Bar     | Barfoo | 5
Bar     | Bargoo | 6
Bar     | Barhoo | 7
Foo     | Foobar | 1
Foo     | Foocar | 2

...组 BarFoo 中的所有列不仅应分组在一起,而且还应在轴上附加一个公共组标签。在 Excel 呈现的示例中:

我目前正在使用 bokeh.models.CategoricalColorMapper 在视觉上分隔组,并在数据源中使用排序使组粘在一起。这很好用,不过我也想要标签。

可在此处查看此功能的文档:

http://docs.bokeh.org/en/latest/docs/user_guide/categorical.html

from bokeh.io import show, output_file
from bokeh.models import ColumnDataSource, FactorRange
from bokeh.plotting import figure

output_file("bars.html")

fruits = ['Apples', 'Pears', 'Nectarines', 'Plums', 'Grapes', 'Strawberries']
years = ['2015', '2016', '2017']

data = {'fruits' : fruits,
        '2015'   : [2, 1, 4, 3, 2, 4],
        '2016'   : [5, 3, 3, 2, 4, 6],
        '2017'   : [3, 2, 4, 4, 5, 3]}

# this creates [ ("Apples", "2015"), ("Apples", "2016"), ("Apples", "2017"), ("Pears", "2015), ... ]
x = [ (fruit, year) for fruit in fruits for year in years ]
counts = sum(zip(data['2015'], data['2016'], data['2017']), ()) # like an hstack

source = ColumnDataSource(data=dict(x=x, counts=counts))

p = figure(x_range=FactorRange(*x), plot_height=250, title="Fruit Counts by Year",
           toolbar_location=None, tools="")

p.vbar(x='x', top='counts', width=0.9, source=source)

p.y_range.start = 0
p.x_range.range_padding = 0.1
p.xaxis.major_label_orientation = 1
p.xgrid.grid_line_color = None

show(p)

请问拉取完成了吗?我无法在 v0.12.7 中复制多级轴,包括提到的所有分类教程 link。

结果:

    ValueError: expected an element of either List(String) 
    or List(Int), got [('3', '6'), ('1', '6'), ('1', '4'), ('3', '3'), ('1', '8'), ('2', '6'), ('3', '4'), ('2', '5'), ('2', '4')]