【问题标题】:Is there a bug in bokeh's stacked bar chart or is it just me?散景的堆积条形图中是否有错误,或者只是我?
【发布时间】:2021-02-18 08:12:51
【问题描述】:

我正在使用 Bokeh 创建一个堆积条形图,我正在努力解决着色问题。传达我的问题的最佳方式可能是显示我的结果: bar chart with wrong use of color in the fourth bar

换句话说:我定义为我的类别颜色'status 8'(深绿色)的颜色被用作第四条顶部的某种框架。这让读者感到非常困惑,因为它得出的结论是,该组件中存在问题,这些问题是 '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'))。这也不起作用。

【问题讨论】:

    标签: python data-visualization bar-chart bokeh


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2020-07-29
      • 1970-01-01
      • 1970-01-01
      • 2021-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-10-23
      • 1970-01-01
      相关资源
      最近更新 更多