- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一些已经运行了一段时间的“分类数据”组。其中一些事情也是同时进行的。我想在 Bokeh Python 的时间轴上显示这些类别。
之后,我尝试抖动它们,但它创建了一些非常困惑和无组织的东西(可能是抖动的点,我只是没有正确使用它。)
理想情况下,我只想要一种方法,允许我在每个类别中交错这些项目,但我不确定如何做。
如有任何建议,我们将不胜感激!
最佳答案
你不想抖动,你想视觉躲闪,也就是demonstrated in the documentation .
from bokeh.io import show
from bokeh.models import ColumnDataSource
from bokeh.plotting import figure
from bokeh.transform import dodge
fruits = ['Apples', 'Pears', 'Nectarines', 'Plums', 'Grapes', 'Strawberries']
years = ['2015', '2016', '2017']
data = {'fruits' : fruits,
'2015' : [2, 1, 4, 3, 2, 4],
'2016' : [5, 3, 3, 2, 4, 6],
'2017' : [3, 2, 4, 4, 5, 3]}
source = ColumnDataSource(data=data)
p = figure(x_range=fruits, y_range=(0, 10), plot_height=250)
p.vbar(x=dodge('fruits', -0.25, range=p.x_range), top='2015', width=0.2, source=source, color="#c9d9d3")
p.vbar(x=dodge('fruits', 0.0, range=p.x_range), top='2016', width=0.2, source=source, color="#718dbf")
p.vbar(x=dodge('fruits', 0.25, range=p.x_range), top='2017', width=0.2, source=source, color="#e84d60")
p.x_range.range_padding = 0.1
p.xgrid.grid_line_color = None
show(p)
或者,您可以使用显式 Categorical Offsets :
fruits = ['Apples', 'Pears', 'Nectarines', 'Plums', 'Grapes', 'Strawberries']
offsets = [-0.5, -0.2, 0.0, 0.3, 0.1, 0.3]
# This results in [ ['Apples', -0.5], ['Pears', -0.2], ... ]
x = list(zip(fruits, offsets))
p.vbar(x=x, top=[5, 3, 4, 2, 4, 6], width=0.8)
关于python - 如何防止 HBar 在 Bokeh 中重叠?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52540568/
我目前正在使用 matplotlib.pyplot 模块来绘制 Pandas 数据框的 float 水平条形图。 我想知道如何在特定段上添加一个带有条形总和/计数的附加条形。换句话说,从下面的代码和图
我有一些已经运行了一段时间的“分类数据”组。其中一些事情也是同时进行的。我想在 Bokeh Python 的时间轴上显示这些类别。 但是,最初的尝试并没有成功: 之后,我尝试抖动它们,但它创建了一些非
我想在视觉上对齐“猫”和“苹果”的标签,使它们出现在同一条“线上”,并对“狗”和“苹果”做同样的事情,而不是让动物标 checkout 现在中间的水果标签列表。这是否可以使用 graph hbar ?
我有一个由 ColumnDataSource 驱动的 hbar 图,其中 y 轴上有分类标签,两个数字 x 轴上有分类标签。为了在 y 轴上每个标签有两组条形,我构造了两个范围 (Things1=df
我是一名优秀的程序员,十分优秀!