Это должно исправить вашу проблему. Этот код удаляет срезы с 0 значениями, как предложил Пол.
import pandas as pd
from bokeh.plotting import figure
from bokeh.io import output_file, show
from bokeh.models.glyphs import Wedge
import math
from bokeh.transform import cumsum
def create_priority_graph(P1, P2, P3):
x = {
'P1': P1,
'P2': P2,
'P3': P3
}
colors = ["#e84d60", "#f2c707", "#718dbf"]
data = pd.Series(x).reset_index(name='value').rename(columns={'index':'toolscore'})
data['angle'] = data['value']/data['value'].sum() * 2*math.pi
data['color'] = colors
data = data[data.value != 0]
p = figure(plot_height=250, plot_width=300, title="Open Issues by priority", toolbar_location=None,tools="hover", tooltips="@toolscore: @value", x_range=(-0.5, 1.0))
p.wedge(x=0, y=1, radius=0.35,start_angle=cumsum('angle', include_zero=True), end_angle=cumsum('angle'),line_color="white", fill_color='color', legend='toolscore', source=data)
p.axis.axis_label=None
p.axis.visible=False
p.grid.grid_line_color = None
return p
p = create_priority_graph(3, 9, 0)
show(p)
Еще один обходной путь, при котором не удаляется легенда для элемента 0:
import pandas as pd
from bokeh.plotting import figure
from bokeh.io import output_file, show
from bokeh.models.glyphs import Wedge
import math
from bokeh.transform import cumsum
def create_priority_graph(P1, P2, P3):
x = {
'P1': P1,
'P2': P2,
'P3': P3
}
for i in x.keys():
if x[i] == 0:
x[i] = 0.0001
colors = ["#e84d60", "#f2c707", "#718dbf"]
data = pd.Series(x).reset_index(name='value').rename(columns={'index':'toolscore'})
data['angle'] = data['value']/data['value'].sum() * 2*math.pi
data['color'] = colors
p = figure(plot_height=250, plot_width=300, title="Open Issues by priority", toolbar_location=None,tools="hover", tooltips="@toolscore: @value", x_range=(-0.5, 1.0))
p.wedge(x=0, y=1, radius=0.35,start_angle=cumsum('angle', include_zero=True), end_angle=cumsum('angle'),line_color="white", fill_color='color', legend='toolscore', source=data)
p.axis.axis_label=None
p.axis.visible=False
p.grid.grid_line_color = None
return p
p = create_priority_graph(3, 9, 0)
show(p)