1
我開始使用散景來繪製不共享x或y變量的數據。我希望能夠選擇一條線,並將其他未選定的線條變灰。理想情況下,選定的線也會被帶到劇情的前面。更改未選擇的散景線的顏色
到目前爲止,我已經能夠找到所選擇的行,但是我找不到一種「灰化」未選中的行或設置所選行的級別的方法。
import numpy as np
from bokeh.plotting import figure, show, output_file
from bokeh.models.sources import ColumnDataSource
from bokeh.models import Line,TapTool
output_file("test.html")
x0s = np.random.randint(0,20,20)
y0s = np.random.randint(0,20,20)
x1s = np.random.randint(0,20,20)
y1s = np.random.randint(0,20,20)
p_left = figure(tools=[TapTool()])
for xs,ys in zip([x0s,x1s],[y0s,y1s]):
source = ColumnDataSource({'x': xs, 'y': ys})
default_line = Line(x='x', y='y', line_color='blue', line_width=2)
selected_line = Line(line_color='red', line_width=4)
nonselected_line = Line(line_color='grey')
p_left.add_glyph(source,default_line,selection_glyph=selected_line,nonselection_glyph=nonselected_line)
show(p_left)
請問您能演示一些腳本嗎?我在嘗試同樣的事情,但它總是選中所有行或者全部未選中 - 我無法從3中選擇一行 – jf328