python-3.x - 未提供 y_range.start 时,散景悬停不适用于零值
问题描述
当未提供 y_range.start 时,散景悬停不适用于值零,例如,在以下代码的情况下,当我们将鼠标悬停在油桃上时,悬停不会显示计数“0”。
from bokeh.io import show, output_file
from bokeh.models import ColumnDataSource
from bokeh.palettes import Spectral6
from bokeh.plotting import figure
from bokeh.transform import factor_cmap
output_file("colormapped_bars.html")
fruits = ['Apples', 'Pears', 'Nectarines', 'Plums', 'Grapes', 'Strawberries']
counts = [5, 3, 0, 2, 5, 6]
data = {'fruits' : fruits, 'counts' : counts}
source = ColumnDataSource(data=dict(fruits=fruits, counts=counts))
p = figure(x_range=fruits, plot_height=250, toolbar_location=None, title="Fruit Counts", tools="hover", tooltips="Count: @counts")
p.vbar(x='fruits', top='counts', width=0.9, source=source, legend="fruits", line_color='white', fill_color=factor_cmap('fruits', palette=Spectral6, factors=fruits))
p.xgrid.grid_line_color = None
show(p)
但是如果我添加p.y_range.start = 0,悬停就可以了。当存在负范围时,悬停也不起作用,例如p.y_range.start = -5
请帮助我在这里做错了什么。
提前致谢。
解决方案
推荐阅读
- python - 将包含另一个具有多个值的字典列表的字典列表转换为数据框
- php - 使用phpspreadsheet在特定列中绑定类型字符串
- firebase - 如何有效地搜索嵌套的用户帖子数据
- html - 使用元素标记关键字而不突出显示它们在语义上是否正确?
- php - 使用 mysqlnd 时如何增加 PHP PDO 最大缓冲区大小?
- python - Maya:Python:如何在脚本编辑器中打开 arnoldRenderView
- apiconnect - IBM API Connect > 封装路径变量
- python - SQLAlchemy 类型装饰器因“对象没有属性“self_group”而失败
- javascript - 如何检测 textContent 何时溢出其父级
- java - 删除 ExpandableListView 中的子项不会在 UI 上更改