Plotly/dash stops updating

I have a graph that’s being updated live.
It does update and I can see the data points being shifted, but after sometime, it stops.
The graph is being updated because I put a counter which shows the number of times the graph was updated and that increases. Except the data points are not shifting after some time. Code is below

import os
import time
import dash
from dash.dependencies import Output, Input, State
import dash_core_components as dcc
import dash_html_components as html
import plotly.offline as py
import random
import plotly.graph_objs as go
from collections import deque
import numpy as np

#import matplotlib.pyplot as plt
import json

data = []
logFile= “odlog.dat”
time = np.zeros(shape=(100, ))
timeArray = np.zeros(shape=(100, ))
odArray = np.zeros(shape=(100, ))

updateInterval = 1000 # We will adjust this from the slider. This is in milliseconds


First of all, we create the app object.

app = dash.Dash(name)

Define layout, which goes to the HTML document in which you will have your plot in.

app.layout = html.Div(children=[
# HTML stuff
html.H1(children=‘Title goes here’),

    Subtitle goes here. You can replace this with a string.
html.Div(id='just_a_text'), # diag text from a different callback function

# Plot goes here.
    id = 'this_is_your_plot' # The software uses this ID to know which figure to include.
    # If you want other UT elements (sliders, fields, etc.), you can put them here.

# Add a slider.
    id = 'the_slider',
    min = 100,
    max = 5000,
    step = 1,
    value = 1000
html.Div(id='slider_return'), # Again, diag, about the slider value.

#  You can trigger a callback function periodically.
    id = 'start_plot',
    interval = 3000, # This is in milliseconds. don't hammer on the system too much.
    n_intervals = 0 # This number will store how many callbacks happened since the software started.


Callback function: Everything you do in the user interface, a callback function gets executed.

# Callback functions work based on ID-s.
# Output is taking a function return value back to the dash.
# Input is when taking an input argument of a function to the function.
# The first argument is the ID you use in the app.layout(), and the subsequent arguments are being handed to the function.
Output(‘this_is_your_plot’, ‘figure’), [Input(‘start_plot’, ‘n_intervals’)] # In this case, the function returns a figure.
def createFigure(n):
# It seems that you HAVE to take in one input argument, even if you don’t use it.
global timeArray
global odArray
global data
global time
with open(logFile,‘r’) as f: # open the log file for reading
for line in f:
data.append(line.split()) # we append the stuff in it into a list

for d in data: #we go through the file to extract some data
    timeArray[:-1] = timeArray[1:]; timeArray[-1] = int(d[0]) #extract time, and then shifting the prevoious one
    odArray[:-1] = odArray[1:]; odArray[-1] = int(d[1]) #same as above except for OD, now we use 2D numpy list
trace1 = go.Scatter(
    x = timeArray,
    y = odArray,
    mode = 'markers'

layout = go.Layout(
        showgrid = True,
        zeroline = True,
        title = "Time"
        showgrid = True,
        zeroline = False,
        title = "Optical Density"
return {
    'data' : [trace1],
    'layout': layout

Output(‘just_a_text’, ‘children’), [Input(‘start_plot’, ‘n_intervals’)]

def display_update_times(n):
return ‘This figure was updated {} times.’.format(n)
#return “Latest timeStamp is {}”.format(timeArray[99])

Output(‘slider_return’, ‘children’), [Input(‘the_slider’, ‘value’)]
def adjustInterval(sliderValue):
global updateInterval
updateInterval = sliderValue
# This function will touch a global variable. Not nice, but eh, oh well.
# return ‘Slider value is {}.’.format(sliderValue)

Start the server.

if name == ‘main’:
app.run_server(debug=True,host=‘’,port=‘8050’) #if you are running @Turbidostat
# app.run_server(debug=True)