散景-堆叠和分组图表 [英] Bokeh - Stacked and grouped charts

查看:47
本文介绍了散景-堆叠和分组图表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在bokeh中创建一个既堆叠又分组的图?有点像 http://www.highcharts.com/demo/column-stacked-and-grouped/.

Is it possible to create a plot in bokeh that is both stacked and grouped? Kinda like http://www.highcharts.com/demo/column-stacked-and-grouped/.

数据集是这样的

   count     date  class    user
    39  2016/12/28    4   user1
    26  2016/12/28    4   user2
    3   2016/12/28    4   user2
    8   2016/12/28    4   user1
    1   2016/12/28    4   user1
    22  2016/12/28    4   user1
    26  2016/12/28    4   user2
    1   2016/12/28    4   user1
    7   2016/12/28    4   user2
    12  2016/12/28    4   user3
    23  2016/12/28    4   user3
    31  2016/12/28    4   user3
    2   2016/12/31    4   user1
    1   2016/12/31    4   user2
    27  2016/12/31    4   user2

我想做的是通过跨类堆叠和跨用户分组来可视化计数,其中x轴的标签为日期.

What I want to do is visualize the counts by stacking across class and grouping across user with the label for x-axis being the dates.

推荐答案

可以.假设您的数据位于pandas数据框(df)中.

Yes you can. Assuming you have your data in a pandas dataframe (df).

这是bokeh文档中的一个示例:对条形图进行分组

Here is an example in the bokeh documentation: Grouping Bar plots

from bokeh.charts import Bar, output_file, show

p = Bar(df, label='date', values='count', stack='class',  group='user',
    )

output_file("bar.html")

show(p)

这篇关于散景-堆叠和分组图表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆