第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

無(wú)法將 Bokeh 中的 CrossHairTool 鏈接到多個(gè)圖

無(wú)法將 Bokeh 中的 CrossHairTool 鏈接到多個(gè)圖

慕蓋茨4494581 2023-06-20 10:45:26
在我的實(shí)現(xiàn)中,十字準(zhǔn)線僅在懸停的情節(jié)中顯示。我目前正在使用 Bokeh 版本2.1.1和 Python Anaconda 版本3.7.6,使用 VSCode 版本 1.48 中的 Python 擴(kuò)展。我不熟悉 Javascript,因此歡迎任何有助于調(diào)試我的代碼以正確顯示跨兩個(gè)圖的十字準(zhǔn)線的幫助。我的代碼:# Importing libraries:import pandas as pdimport randomfrom datetime import datetime, timedeltafrom bokeh.models import CustomJS, CrosshairTool, ColumnDataSource, DatetimeTickFormatter, HoverToolfrom bokeh.layouts import gridplotfrom bokeh.plotting import figure, output_file, show# Function wrote by Hamid Fadishei to enable a linked crosshair within gridplot:def add_vlinked_crosshairs(figs):? ? js_leave = ''? ? js_move = 'if(cb_obj.x >= fig.x_range.start && cb_obj.x <= fig.x_range.end &&\n'? ? js_move += 'cb_obj.y >= fig.y_range.start && cb_obj.y <= fig.y_range.end){\n'? ? for i in range(len(figs)-1):? ? ? ? js_move += '\t\t\tother%d.spans.height.computed_location = cb_obj.sx\n' % i? ? js_move += '}else{\n'? ? for i in range(len(figs)-1):? ? ? ? js_move += '\t\t\tother%d.spans.height.computed_location = null\n' % i? ? ? ? js_leave += '\t\t\tother%d.spans.height.computed_location = null\n' % i? ? js_move += '}'? ? crosses = [CrosshairTool() for fig in figs]? ? for i, fig in enumerate(figs):? ? ? ? fig.add_tools(crosses[i])? ? ? ? args = {'fig': fig}? ? ? ? k = 0? ? ? ? for j in range(len(figs)):? ? ? ? ? ? if i != j:? ? ? ? ? ? ? ? args['other%d'%k] = crosses[j]? ? ? ? ? ? ? ? k += 1? ? ? ? fig.js_on_event('mousemove', CustomJS(args=args, code=js_move))? ? ? ? fig.js_on_event('mouseleave', CustomJS(args=args, code=js_leave))
查看完整描述

1 回答

?
繁花如伊

TA貢獻(xiàn)2012條經(jīng)驗(yàn) 獲得超12個(gè)贊

這是一個(gè)適用于 Bokeh 2.2.1 的解決方案:只需對(duì)所有需要它鏈接的圖使用相同的十字準(zhǔn)線工具對(duì)象。像這樣:

import numpy as np

from bokeh.plotting import figure, show

from bokeh.layouts import gridplot

from bokeh.models import CrosshairTool


plots = [figure() for i in range(6)]

[plot.line(np.arange(10), np.random.random(10)) for plot in plots]


linked_crosshair = CrosshairTool(dimensions="both")


for plot in plots:

? ? plot.add_tools(linked_crosshair)


show(gridplot(children=[plot for plot in plots], ncols=3))


查看完整回答
反對(duì) 回復(fù) 2023-06-20
  • 1 回答
  • 0 關(guān)注
  • 211 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)