title: Looping an animation using Bokeh
body: <p>I'm new to Bokeh and Python, and this is my first Stack Overflow question as well.</p>
  
  <p>I'm using Bokeh to plot trajectory profiles of particles diffusing in the brain, but have it be animated.  I have been able to successfully create a program that plots the points, but once all the points are plotted, it stops.  I want to be able to loop the animation so that once all the points are plotted, it clears itself and starts over. </p>
  
  <p>I am still very unfamiliar with coding terms, and I wasn't able to find something that could do this.  I thought I was on the right track with importing using the reset function inside an if statement, but it doesn't seem to work.  I have looked at the following as well for reference:</p>
  
  <p><a href="https://stackoverflow.com/questions/31008714/how-to-animate-a-circle-using-bokeh">How to animate a circle using bokeh</a></p>
  
  <p>Here is my code so far plotting a random trajectory:</p>
  
  <pre><code>import numpy as np
  from bokeh.plotting import figure, show, gridplot, vplot, hplot, curdoc
  from bokeh.io import output_notebook
  from bokeh.client import push_session
  from bokeh.core.state import State as new
  
  # This is where the actual coding begins.
  b = np.random.rand(300, 3)
  xlist = b[:, 1]
  ylist = b[:, 2]
  
  # create a plot and style its properties.  Change chart title here.
  p = figure(title='PEG_PLGA15k_F68_R2_P81', title_text_font_size='13pt',
         x_range=(min(xlist), max(xlist)), y_range=(min(ylist), max(ylist)),)
  
  # add a text renderer to out plot (no data yet)
  r = p.line(x=[], y=[], line_width=3, color='navy')
  
  session = push_session(curdoc())
  
  i = 0
  ds = r.data_source
  
  
  # create a callback that will add a number in a random location
  def callback():
      global i
      ds.data['x'].append(xlist[i])
      ds.data['y'].append(ylist[i])
      ds.trigger('data', ds.data, ds.data)
      if i &lt; xlist.shape[0] - 1:
          i = i + 1
      else:
          new.reset()
  
  # Adds a new data point every 67 ms.  Change at user's discretion.
  curdoc().add_periodic_callback(callback, 67)
  
  session.show()
  
  session.loop_until_closed()
  </code></pre>