我试图突出显示一个图和两个表中的数据点。两个表的数据源不同,可以通过列a链接。
我想点击绘图中的一个数据点,表1中相应的数据点突出显示(使用下面的代码)。此外,我想突出显示表2中具有相同a列值的所有数据点,或者至少是与所选id对应的第一个数据点。
另外,是否可以调整高亮显示行的颜色?
from bokeh.models.widgets import Panel, Tabs, TableColumn,DataTable, Div
import numpy as np
from bokeh.io import show
from bokeh.layouts import layout
import bokeh.plotting
from bokeh.models import ColumnDataSource, HoverTool
columns = [
TableColumn(field="A", title="A"),
TableColumn(field="B", title="B"),
TableColumn(field="C", title="C"),
TableColumn(field="D", title="D"),]
data1 = {"A":['ID1','ID2','ID3','ID4','ID5','ID6','ID7','ID8','ID9','ID10'],
"B": np.random.randint(10, 20, 10),
"C": np.random.randint(10, 20, 10),
"D": np.random.randint(10, 20, 10)}
source1 = ColumnDataSource(data1)
p1 = DataTable(source=source1, columns=columns, width=300, height=200,editable=True)
data2 = {"A":['ID1','ID1','ID1','ID1','ID2','ID2','ID4','ID7','ID9','ID10'],
"B": np.random.randint(10, 20, 10),
"C": np.random.randint(10, 20, 10),
"D": np.random.randint(10, 20, 10)}
source2 = ColumnDataSource(data2)
p2 = DataTable(source=source2, columns=columns, width=300, height=200,editable=True)
dumbdiv = Div(text=""" """, width=1, height=20)
hover1 = HoverTool(tooltips=[("A", "@A")])
tools1 = ["tap","pan","box_zoom","wheel_zoom","save","reset", hover1]
p = bokeh.plotting.figure(width=400,height=200,x_axis_type="datetime",
background_fill_color="lightgray", tools=tools1)
p.circle(x="B",y="C",source=source1, size=10)
l1 = layout([[p, p1, p2]], sizing_mode='fixed')
tab1 = Panel(child=l1, title="Three Tables")
tabs = Tabs(tabs=[tab1],sizing_mode='scale_width')
show(tabs)
暂无答案!
目前还没有任何答案,快来回答吧!