내 Bokeh 스트리밍 플롯은 빈 사각형입니다. 실시간으로 업데이트되지 않는 간단한 선 그림을 만들 수 있습니다. Bokeh 버전의 Bokeh 설명서를 읽었습니다. 0.12.10과 Python3.5.3을 사용하고 있습니다. 나는 온라인에서 오류 메시지에 대한 해결책을 광범위하게 검색했다.Bokeh 스트리밍 플롯이 비어 있음
나는 오류 내가 센서에서 데이터를 검색 pyserial를 사용하고
Error thrown from periodic callback: ValueError('All streaming column updates must be the same length')
을 얻고있다. 예제 값은 온도가 73.40이고 시간이 12:30:42입니다. 이 데이터를 실시간으로 플롯하려고합니다. 여기
코드입니다 : 예제 코드가 자체 포함되지import serial
from bokeh.io import curdoc
from bokeh.models import ColumnDataSource
from bokeh.plotting import figure, output_file, show
ser = serial.Serial('/dev/ttyACM0', 9600)
source = ColumnDataSource(dict(time=[], sensor=[]))
p = figure(plot_height=400, plot_width=1200, title="Fahrenheit Plotting")
p.title.text = "Fahrenheit Plotter"
p.title.text_color = "blue"
p.title.text_font = "arial"
p.title.text_font_style = "bold"
p.yaxis.minor_tick_line_color = "yellow"
p.xaxis.axis_label = "Time"
p.yaxis.axis_label = "Fahrenheit"
p.line(x='time', y='sensor',line_width=3,color="blue",alpha=0.8,source=source)
def update():
while True:
arduinoString = ser.readline()
data_array = str(arduinoString).split(',')
time = data_array[1]
sensor1 = data_array[2]
print(sensor)
print(time)
new_data = dict(time=[], sensor1=[])
new_data['time'] = data_array[1]
new_data['sensor'] = data_array[2]
source.stream(new_data, 20)
curdoc().add_root(p)
curdoc().add_periodic_callback(update, 100)
curdoc().title = "Device Temperatures"
감사합니다. 나는 온도 줄과 센서 줄을 같은 길이로 만들었습니다 :'00072 : 94''12 : 55 : 33'. 더 이상 오류 메시지가 표시되지 않습니다. – tluafed