在bokeh中是否可以在一个轴上有多个级别的标签?也就是说,对于像这样的数据源
TheBars | ThFoos | TheValues
--------|--------|----------
Bar | Barfoo | 5
Bar | Bargoo | 6
Bar | Barhoo | 7
Foo | Foobar | 1
Foo | Foocar | 2..。组Bar和Foo中的所有列不仅要分组在一起,而且要有一个共同的组标签贴在轴上。在Excel呈现的示例中:

我目前正在使用bokeh.models.CategoricalColorMapper在视觉上分离分组,并使用数据源中的排序来使分组粘合在一起。这个很好用,不过我也想要标签。
发布于 2017-07-25 04:37:09
有关此功能的文档可在此处查看:
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)

发布于 2017-10-09 21:26:41
我想知道拉动是不是已经完成了?我不能在v0.12.7中复制多级轴,包括所有提到的分类教程链接。
结果:
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')]https://stackoverflow.com/questions/45274734
复制相似问题