bokeh 的堆积条形图是否有错误,或者只是我?

Is there a bug in bokeh's stacked bar chart or is it just me?

我正在使用 Bokeh 创建堆叠条形图,但我在着色方面遇到了困难。传达我的问题的最佳方式可能是显示我的结果: bar chart with wrong use of color in the fourth bar

简而言之:我定义为我的类别颜色 'status 8'(深绿色)的颜色被用作第四个栏顶部的某种框架。这对于 reader 来说非常混乱,因为它得出的结论是 'status 8' 的组件中存在问题 - 即使没有,这就是为什么我想解决这个问题并摆脱“框架”。

这是我创建情节的代码:

from bokeh.plotting import figure
from bokeh.palettes import RdYlGn8
from bokeh.io import show
import math

components = ['1.1 Component 1', '1.2 Component 2', '3.1 Component 3', '4.5 Component 4']
status = ['status 1', 'status 2', 'status 3', 'status 4', 'status 5', 'status 6', 'status 7', 'status 8']

csd = {'components': ['1.1 Component 1', '1.2 Component 2', '3.1 Component 3', '4.5 Component 4'],
        'status 1': [0, 4, 12, 1],
        'status 2': [0, 0, 10, 1],
        'status 3': [0, 0, 5, 0],
        'status 4': [0, 3, 17, 0],
        'status 5': [0, 2, 36, 0],
        'status 6': [0, 0, 1, 0],
        'status 7': [0, 20, 0, 0],
        'status 8': [5, 26, 24, 0]}

colors = RdYlGn8[::-1]

plot = figure(x_range=components, plot_height=600, plot_width=1400, title="Issues per Component",
              toolbar_location=None, tools="hover", tooltips="$name: @$name")

plot.vbar_stack(status, x='components', width=0.9, color=colors, source=csd, legend_label=status)
plot.y_range.start = 0
plot.legend.location = "top_left"
plot.legend.orientation = "horizontal"
plot.x_range.range_padding = 0.1
plot.xaxis.major_label_orientation = math.pi / 4

show(plot)

顺便说一句,我也尝试过手动定义颜色,如元组和列表(例如 ('#d73027', '#f46d43', '#fdae61', '#fee08b', '#d9ef8b', '#a6d96a', '#66bd63', '#1a9850'))。这也没有用。

这是(零高度)栏的轮廓。如果您不想绘制轮廓,则必须将 line_color 设置为 None。