My Bokeh Streaming Plot is a blank rectangle. I am able to create a simple line plot that does not update itself in real-time. I have read the Bokeh documentation for the version of Bokeh I am using 0.12.10 and Python3.5.3. I have searched on-line extensively for a solution to the error message.
I am getting the error
Error thrown from periodic callback: ValueError('All streaming column updates must be the same length')
I am using pyserial to retrieve data from a sensor. The example values are 73.40 for temperature and 12:30:42 for the time. I want to plot this data in real-time.
Here is the code:
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"