为散景条形图的不同值创建颜色图

时间:2020-06-08 14:46:55

标签: python pandas plot bokeh

我有以下条形图:

,每个小节的时间戳记均为15分钟。我想做的是在某个时间戳记之前给这些条提供不同的颜色。我不确定该怎么做。

    # Set range Y-Axis to show relative traffic intensity when comparing different VRI numbers
    bottom = 0
    top = 500



    # Specify the source for the bar plot
    source = ColumnDataSource(data)

    # Specify plot
    p = figure(x_axis_type='datetime', title='Total traffic intensity for VRI {} and Bron {}'.format(vri_number, bron), plot_width=1000, y_range=(bottom, top))
    p.vbar(x='van_timestamp', top='aantal', width=timedelta(minutes=12), source=source, hover_line_color="black", alpha=1)


    # X and Y labels
    p.xaxis.axis_label = 'Time'
    p.yaxis.axis_label = 'Traffic intensity'



    hover = HoverTool(tooltips=
                      [
        ('Time', '@van_timestamp{%Y-%m-%d %H:%M}'),
        ('Traffic Intensity', '@aantal'),
        ('VRI Number', '@vri')],
        formatters={'@van_timestamp': 'datetime'},)

    p.add_tools(hover)


    show(p)

这是数据的样子:

    van_timestamp         aantal    bron      vri
0   2017-09-30 00:00:00     6        2        309
1   2017-09-30 00:00:00     2        42       324
2   2017-09-30 00:00:00     3        48       308
3   2017-09-30 00:00:00     41       4        324
4   2017-09-30 00:00:00     19       8        307

aantal在Y轴上绘制,而van_timestamp在x轴上绘制

0 个答案:

没有答案