问题
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/.
The dataset is something like this
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
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.
回答1:
Yes you can. Assuming you have your data in a pandas dataframe (df).
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)
来源:https://stackoverflow.com/questions/41432613/bokeh-stacked-and-grouped-charts