에서 데이터 소스를 변경합니다. 그러나 플롯을 업데이트 할 수 없습니다. 내가 뭘 잘못 했니? 또는 더 좋은 방법이 있습니까?는 어떻게 선택 상자를 기반으로 플롯을 변경하려면 데이터 소스를 업데이트하려고 보케와 파이썬 2.7</p> <p>임을 사용하고 선택 보케
코드 :
from bokeh.models import ColumnDataSource
from bokeh.plotting import figure, output_file, show, output_notebook
from bokeh.models.widgets import Select
from bokeh.io import curdoc
from bokeh.layouts import column, row
from bokeh.io import output_file, show
from bokeh import models
import pandas as pd
d1 = dict(x= [10,4,6,4], y = [6,2,8,10])
d2 = dict(x= [23,12,50,30], y = [5,10,23,18,12])
source = ColumnDataSource(data=d1)
p = figure()
select = Select(title="Select d", options=['d1', 'd2'])
def update_plot(attrname, old, new):
if new == 'd1':
newSource = d1
if new == 'd2':
newSource = d2
source.data = newSource
p.line(x='x', y='y',source = source)
select.on_change('value', update_plot)
layout = column(row(select, width=400), p)
curdoc().add_root(layout)
show(layout)
'update_plot'이 실행되었는지 확인 하시겠습니까? on_change없이'update_plot'을 직접 호출 해 보았습니까? – hansaplast
update_plot이 트리거되었는지 어떻게 확인할 수 있습니까? 필요한 'boolean'문서를 읽었습니다. 'on_change'함수 –
'update_plot' 내에'print ('hello')'명령문을 추가 할 수 있습니까? – hansaplast