Bokehサーバーを使用してプロット内に線として表示したい列のパンダデータフレームがあります。さらに、私は線の1つを他の線に対してシフトするためのスライダーを持っていたいと思います。Bokeh:pandasデータフレームのグラフがトリガーで更新されない
私の問題は、スライダの値が変更されたときの更新機能です。私はボケの例のスライダーからコードを試しましたが、うまくいきません。ここで
を例update_data
-functionインサイド
import pandas as pd
from bokeh.io import vform
from bokeh.plotting import Figure, output_file, show
from bokeh.models import CustomJS, ColumnDataSource, Slider
df = pd.DataFrame([[1,2,3],[3,4,5]])
df = df.transpose()
myindex = list(df.index.values)
mysource = ColumnDataSource(df)
plot = Figure(plot_width=400, plot_height=400)
for i in range(len(mysource.column_names) - 1):
name = mysource.column_names[i]
plot.line(x = myindex, y = str(name), source = mysource)
offset = Slider(title="offset", value=0.0, start=-1.0, end=1.0, step=1)
def update_data(attrname, old, new):
# Get the current slider values
a = offset.value
temp = df[1].shift(a)
#to finish#
offset.on_change('value', update_data)
layout = vform(offset, plot)
show(layout)
である私はmysource
を更新する必要がありますが、私はそれを行う方法を見つけ出すことはできません。誰かが私を正しい方向に向けることができますか?あなたはそれがあなたの代わりにoffset.on_change('value', update_data)
のupdate_data
機能でやろうとしているであるものは何でもした後