但是我使用的是bokeh0.13.0,所以对于每种颜色我只有fill\u color='color'。
这不是真的。这个
color
参数可用于任何glyph方法(包括
wedge
fill_color
和
line_color
同时。您的问题有些令人困惑,因为调色板的大小与数据的大小不匹配,但下面是一个完整的示例,仅使用调色板,截断:
from collections import Counter
from math import pi
import pandas as pd
from bokeh.io import output_file, show
from bokeh.plotting import figure
from bokeh.transform import cumsum
chart_colors = ['#44e5e2', '#e29e44', '#e244db',
'#d8e244', '#eeeeee', '#56e244', '#007bff', 'black']
x = Counter({
'Submitted': 179,
'Approved': 90,
'Denied': 80
})
data = pd.DataFrame.from_dict(dict(x), orient='index').reset_index().rename(
index=str, columns={0: 'value', 'index': 'claimNumber'})
data['angle'] = data['value']/sum(x.values()) * 2*pi
data['color'] = chart_colors[:len(x)]
p = figure(plot_height=350, title="Pie Chart", toolbar_location=None)
p.wedge(x=0, y=1, radius=0.28,
start_angle=cumsum('angle', include_zero=True), end_angle=cumsum('angle'),
color='color', legend='claimNumber', source=data)
p.axis.axis_label=None
p.axis.visible=False
p.grid.grid_line_color = None
show(p)