1
共通のxまたはy変数を共有しないデータをプロットするためにBokehを使い始めました。私は、行を選択し、選択されていない他の行を灰色で表示することができるようにしたいと思います。理想的には、選択された線もプロットの前面に移動されます。選択されていないBokeh線の色を変更
これまでのところ、私は行を選択することができましたが、選択されていない行を「グレーアウト」する方法や選択した行のレベルを設定する方法が見つかりませんでした。
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行のうち1行は選択できません – jf328