首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Bokeh categorical_bar_stacked

Bokeh categorical_bar_stacked
EN

Stack Overflow用户
提问于 2018-09-04 21:48:18
回答 1查看 73关注 0票数 0

我需要调整堆叠图的Bokeh Example以适应我的数据,我遵循了相同的模式,但是当我运行代码时,以下错误出现了ValueError: Keyword argument sequences for broadcasting must all be the same lengths. Got lengths: [5, 6]

在我的代码下面,它是我的数据片段,数据分散了几天

代码语言:javascript
复制
from bokeh.core.properties import value
from bokeh.io import show, output_file
from bokeh.plotting import figure
output_file("stacked.html")

time = ['2018-08-06 00:00:00', '2018-08-06 01:00:00', '2018-08-06 02:00:00',
    '2018-08-06 03:00:00', '2018-08-06 04:00:00', '2018-08-06 05:00:00']
boards = ['GPHB_00-40', 'GPHB_41-60', 'GPHB_61-80', 'GPHB_81-90', 'GPHB_91-100']
colors = ['#2b83ba', '#abdda4', '#ffffbf', '#fdae61', '#d7191c']

data = {'time'         : time,
        'GPHB_00-40'   : [95, 99, 99, 100, 100, 100, 100, 95, 69, 55],
        'GPHB_41-60'   : [4,  1,  1,  0,   0,   0,   0,   4,  20, 34],
        'GPHB_61-80'   : [1,  0,  0,  0,   0,   0,   0,   1,  5,  8 ],
        'GPHB_81-90'   : [0,  0,  0,  0,   0,   0,   0,   0,  4,  2 ],
        'GPHB_91-100'  : [0,  0,  0,  0,   0,   0,   0,   0,  2,  1 ]}

p = figure(x_range=time, plot_height=250, title="Boards Load",
           toolbar_location=None, tools="")

p.vbar_stack(boards, x='time', width=0.9, color=colors, source=data,
             legend=[value(x) for x in time])

p.y_range.start = 0
p.x_range.range_padding = 0.1
p.xgrid.grid_line_color = None
p.axis.minor_tick_line_color = None
p.outline_line_color = None
p.legend.location = "top_left"
p.legend.orientation = "horizontal"

show(p)
EN

回答 1

Stack Overflow用户

发布于 2018-09-06 01:13:05

我已经找到解决方案了,代码中有一个错误

代码语言:javascript
复制
p.vbar_stack(boards, x='time', width=0.9, color=colors, source=data,
         legend=[value(x) for x in time])

时间上的参考是错误的,它应该参考董事会

代码语言:javascript
复制
p.vbar_stack(boards, x='time', width=0.9, color=colors, source=data,
         legend=[value(x) for x in boards])
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52167855

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档