- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在创建 Bokeh 时遇到了一个小问题 vbar 在 0.13.0
来自数据帧 groupby
count
手术。回复 here是一个多层次的团体,而我的却不是。
发布后的更新
('ResponseID','RateGeneral','RateAccomodation','RateClean','RateServices')
并且 dtype 被设置为类别。我想通过使用显示响应计数组的 Bokeh vbar
DemoDFCount = DemoDF.groupby('RateGeneral').count()
pTest= figure(title='Rating in General',plot_height=350)
pTest.vbar(width=0.9,source=DemoDFCount, x='RateGeneral',top='ResponseID')
show(pTest))
DemoDFCount.plot.bar(legend=False)
我可以绘制一些东西,但如何在 Bokeh 中创建此图表?
DemoDF.to_json()
的 50 行样本数据
'{"ResponseID":{"0":1,"1":2,"2":3,"3":4,"4":5,"5":6,"6":7,"7":8,"8":9,"9":10,"10":11,"11":12,"12":13,"13":14,"14":15,"15":16,"16":17,"17":18,"18":19,"19":20,"20":21,"21":22,"22":23,"23":24,"24":25,"25":26,"26":27,"27":28,"28":29,"29":30,"30":31,"31":32,"32":33,"33":34,"34":35,"35":36,"36":37,"37":38,"38":39,"39":40,"40":41,"41":42,"42":43,"43":44,"44":45,"45":46,"46":47,"47":48,"48":49,"49":50},"RateGeneral":{"0":"Good","1":"Satisfactory","2":"Good","3":"Poor","4":"Good","5":"Satisfactory","6":"Excellent","7":"Good","8":"Good","9":"Satisfactory","10":"Satisfactory","11":"Excellent","12":"Satisfactory","13":"Excellent","14":"Satisfactory","15":"Very Good","16":"Satisfactory","17":"Excellent","18":"Very Good","19":"Excellent","20":"Satisfactory","21":"Good","22":"Satisfactory","23":"Excellent","24":"Satisfactory","25":"Good","26":"Excellent","27":"Very Good","28":"Good","29":"Very Good","30":"Good","31":"Satisfactory","32":"Very Good","33":"Very Good","34":"Very Good","35":"Good","36":"Excellent","37":"Satisfactory","38":"Excellent","39":"Good","40":"Good","41":"Satisfactory","42":"Very Good","43":"Very Good","44":"Poor","45":"Excellent","46":"Good","47":"Excellent","48":"Satisfactory","49":"Good"},"RateAccomodation":{"0":"Very Good","1":"Excellent","2":"Satisfactory","3":"Satisfactory","4":"Good","5":"Good","6":"Very Good","7":"Very Good","8":"Good","9":"Satisfactory","10":"Satisfactory","11":"Excellent","12":"Satisfactory","13":"Excellent","14":"Good","15":"Very Good","16":"Good","17":"Excellent","18":"Excellent","19":"Very Good","20":"Good","21":"Satisfactory","22":"Good","23":"Excellent","24":"Satisfactory","25":"Very Good","26":"Excellent","27":"Excellent","28":"Good","29":"Very Good","30":"Very Good","31":"Very Good","32":"Excellent","33":"Very Good","34":"Very Good","35":"Very Good","36":"Excellent","37":"Satisfactory","38":"Excellent","39":"Good","40":"Excellent","41":"Poor","42":"Very Good","43":"Very Good","44":"Poor","45":"Excellent","46":"Satisfactory","47":"Excellent","48":"Good","49":"Good"},"RateClean":{"0":"Excellent","1":"Excellent","2":"Satisfactory","3":"Good","4":"Excellent","5":"Very Good","6":"Very Good","7":"Excellent","8":"Excellent","9":"Satisfactory","10":"Satisfactory","11":"Excellent","12":"Good","13":"Good","14":"Excellent","15":"Excellent","16":"Good","17":"Excellent","18":"Excellent","19":"Excellent","20":"Good","21":"Very Good","22":"Poor","23":"Very Good","24":"Satisfactory","25":"Very Good","26":"Excellent","27":"Good","28":"Poor","29":"Good","30":"Excellent","31":"Good","32":"Good","33":"Very Good","34":"Satisfactory","35":"Good","36":"Excellent","37":"Satisfactory","38":"Excellent","39":"Good","40":"Very Good","41":"Satisfactory","42":"Excellent","43":"Excellent","44":"Very Good","45":"Excellent","46":"Good","47":"Excellent","48":"Good","49":"Excellent"},"RateServices":{"0":"Very Good","1":"Excellent","2":"Good","3":"Good","4":"Excellent","5":"Good","6":"Good","7":"Very Good","8":"Good","9":"Satisfactory","10":"Satisfactory","11":"Excellent","12":"Good","13":"Very Good","14":"Good","15":"Excellent","16":"Poor","17":"Excellent","18":"Excellent","19":"Excellent","20":"Good","21":"Good","22":"Very Good","23":"Excellent","24":"Satisfactory","25":"Very Good","26":"Excellent","27":"Very Good","28":"Good","29":"Excellent","30":"Very Good","31":"Excellent","32":"Good","33":"Excellent","34":"Very Good","35":"Very Good","36":"Excellent","37":"Satisfactory","38":"Excellent","39":"Good","40":"Very Good","41":"Satisfactory","42":"Excellent","43":"Excellent","44":"Good","45":"Excellent","46":"Very Good","47":"Excellent","48":"Good","49":"Very Good"}}'
最佳答案
在另一个问题中它是多层次的这一事实并不真正相关。当您使用 Pandas 时 GroupBy
作为 Bokeh 的数据源,Bokeh 使用 group.describe
的结果(包括每组每列的计数)作为数据源的内容。这是一个完整的示例,显示了来自“汽车”数据集的 Counts-per-Origin:
from bokeh.io import show, output_file
from bokeh.plotting import figure
from bokeh.sampledata.autompg import autompg as df
output_file("groupby.html")
df.origin = df.origin.astype(str)
group = df.groupby('origin')
p = figure(plot_height=350, x_range=group, title="Count by Origin",
toolbar_location=None, tools="")
# using yr_count, but count for any column would work
p.vbar(x='origin', top='yr_count', width=0.8, source=group)
p.y_range.start = 0
p.xgrid.grid_line_color = None
show(p)
关于bokeh - 如何将 GroupBy Count 显示为分类数据的 Bokeh vbar,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51499376/
问题 是否可以将悬停工具与 Bokeh vbar 字形一起使用? 问题 使用相同的基本设置,我可以使用circle字形上的悬停工具获得很好的工具提示,但不能在vbar字形上获得很好的工具提示 演示 设
我想制作一些简单数据的条形图,例如像这样的 Pandas 数据框。 Cats 4 Dogs 3 Mice 27 我想要一个工具提示,当鼠标悬停在栏上时显示如下内容: Name: Cats Count:
我准备了两个 ColumnDataSource,它们的 y 轴数据集不同。 plot.line('x', 'y', source=source, line_width=2) plot.
尝试将以下内容读入 vbar Bokeh 图表,但它不会渲染空白图形之外的任何内容。 Index | Sub Call Type | Calls |Total AHT 0 | S
我希望在 Bokeh 绘图中使用 vbar 方法绘制条形图,其中 x 轴采用分类值而不是数字值。教程页面 ( http://docs.bokeh.org/en/latest/docs/referenc
我刚刚开始研究 Bokeh 的数据可视化,并且想知道使用 Figure.vbar() 与 Bar() 的优点/缺点,如果有人可以澄清一下。 最佳答案 bar 来自高级图表界面。它使您可以快速、轻松地访
我在创建 Bokeh 时遇到了一个小问题 vbar 在 0.13.0 来自数据帧 groupby count手术。回复 here是一个多层次的团体,而我的却不是。 发布后的更新 根据提供的答案添加了示
我正在尝试将 Bokeh 字形与 CSV 文件(或多个文件)中的数据结合使用。我知道我们可以使用 CSV 读取器导入 CSV,但是如何让 Bokeh 将其用于字形? from bokeh.plotti
我有一个 vbar 绑定(bind)到一个 ColumnDataSource,它根据一些小部件选择进行更新。如果我从 line_width=5 开始,我的初始数据看起来很棒。但是,当我更新图表时,x_
我想使用 Bokeh 绘制一个 vbar 图,其中 x 轴采用日期时间,y 轴采用分类值。 最初我尝试了如下圆图: import pandas as pd from datetime import d
这肯定会使条形宽度变宽,但最好将它们设置为“1 天”宽: source = ColumnDataSource(df) p = figure(x_axis_type="datetime", height
我是一名优秀的程序员,十分优秀!