为了账号安全,请及时绑定邮箱和手机立即绑定

散景工具提示获得Y值顶部

散景工具提示获得Y值顶部

侃侃尔雅 2022-09-27 10:40:03
我有以下代码,但是在工具提示中,我想显示每个vbar的y_value。from bokeh.io import output_file, showfrom bokeh.models import ColumnDataSourcefrom bokeh.plotting import figurefrom bokeh.transform import dodgeoutput_file("dodged_bars.html")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, title="Fruit Counts by Year",           toolbar_location=None, tools="", tooltips=[('Count', '$y_max')])p.vbar(x=dodge('fruits', -0.25, range=p.x_range), top='2015', width=0.2, source=source,       color="#c9d9d3", legend="2015 ")p.vbar(x=dodge('fruits',  0.0,  range=p.x_range), top='2016', width=0.2, source=source,       color="#718dbf", legend="2016 ")p.vbar(x=dodge('fruits',  0.25, range=p.x_range), top='2017', width=0.2, source=source,       color="#e84d60", legend="2017 ")p.x_range.range_padding = 0.1p.xgrid.grid_line_color = Nonep.legend.location = "top_left"p.legend.orientation = "horizontal"show(p)有没有办法相应地显示每个vbar的y_value?散景显示
查看完整描述

1 回答

?
繁华开满天机

TA贡献1816条经验 获得超4个赞

你需要做两件事:

  1. 将参数添加到与其 具有相同值的每个 ,例如namevbartopname='2015'

  2. 替换为 in'$y_max''@$name'tooltips


查看完整回答
反对 回复 2022-09-27
  • 1 回答
  • 0 关注
  • 51 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信