[英]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'
(深綠色)的顏色被用作第四條頂部的某種框架。 這讓讀者感到非常困惑,因為它得出的結論是,該組件中存在屬於'status 8'
問題——即使沒有,這就是為什么我想解決這個問題並擺脫“框架”。
這是我創建 plot 的代碼:
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)
順便說一句,我還嘗試手動將 colors 定義為元組和列表(例如('#d73027', '#f46d43', '#fdae61', '#fee08b', '#d9ef8b', '#a6d96a', '#66bd63', '#1a9850')
)。 這也不起作用。
那是(零高度)條的輪廓。 如果您不想繪制輪廓,則必須將line_color
設置為 None。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.