Bokeh Interactive mode: how to show only last values and not squeezing the whole dataset?

Adding a point to a dynamic plot the whole dataset visualization is squeezed to accomodate all points.
How is it possible to show only the last, say, 10000 points without removing older points from the dataset?
I am missing this figure property and I am sure it is under my nose…

This is the code, taken from http://stackoverflow.com/questions/37724660/streaming-two-line-graphs-using-bokeh

#!/usr/bin/python

-- coding: utf-8 -

myplot.py

from bokeh.plotting import figure, curdoc
from bokeh.driving import linear
import random

p = figure(plot_width=400, plot_height=400)
r1 = p.line(, , color=“firebrick”, line_width=2)
r2 = p.line(, , color=“navy”, line_width=2)

ds1 = r1.data_source
ds2 = r2.data_source

@linear()
def update(step):
ds1.data[‘x’].append(step)
ds1.data[‘y’].append(random.randint(0,100))
ds2.data[‘x’].append(step)
ds2.data[‘y’].append(random.randint(0,100))
ds1.trigger(‘data’, ds1.data, ds1.data)
ds2.trigger(‘data’, ds2.data, ds2.data)

curdoc().add_root§
curdoc().add_periodic_callback(update, 100)

``

(For the ones interested in the topic, this is the answer Bryan Van de ven sent to me on another thread)

You can try setting the .follow and .follow_interval on a DataRange1d:

    [http://bokeh.pydata.org/en/latest/docs/reference/models/ranges.html#bokeh.models.ranges.DataRange1d.follow](http://bokeh.pydata.org/en/latest/docs/reference/models/ranges.html#bokeh.models.ranges.DataRange1d.follow)

This is similar to what you ask, it will allow you to control over the width of the x-range in data space, e.g. But there is nothing currently built into Bokeh that allows you to control by specifying “last N points”. For that you would have to write some kind of custom extension.

However, be advised that streaming data into the browser indefinitely is effectively an intentional memory leak – do it for long
enough or at a high enough rate and the browser will eventually become very unhappy. It’s for this reason that the .stream method on column data sources accept a “rollover” limit to automatically truncate data source columns. Of course, you could handle periodically truncating your
data source columns manually somehow too.

As an aside, there has been interest in developing the “dataframe” qualities of CDS on the JS side, so things like slices could be used to inform glyph renderers. It’s just obviously not a trivial task, and no one has been available to work on it yet.

Thanks,

Bryan