Constantly updating the window?

Hey, I wrote the following program that basically updates a graph with a random new value as time passes.

import time

import random

from random import shuffle

from bokeh.plotting import figure, output_server, cursession, show, Session

session = Session(root_url=‘http://127.0.0.1:5006/’, load_from_config=False)

session.register(‘anon3’, ‘1234’)

session.login(‘anon’, ‘1234’)

output_server(“animated_line”)

a = random.random()*10

b = random.random()*10

p = figure(plot_width=1000, plot_height=600)

p.xaxis.bounds = (1,100)

p.line([0], [a], name=‘ex_line1’)

p.line([0], [b], name=‘ex_line2’)

show§

renderer1 = p.select(dict(name=“ex_line1”))

ds1 = renderer1[0].data_source

renderer2 = p.select(dict(name=“ex_line2”))

ds2 = renderer2[0].data_source

i = 0

while True:

a1 = random.random()*10

b1 = random.random()*10

ds1.data[“x”].append(i)

ds2.data[“x”].append(i)

ds1.data[“y”].append(a1)

cursession().store_objects(ds1)

cursession().store_objects(ds2)

time.sleep(0)

i+= 1

The problem is that the axes sorta squish up as the values begin to get large (as shown here: https://gyazo.com/30be6427d6a2308219d9fbf2cb9a25c5 )
I was wondering if there’s a way for us to manually adjust the window so that we can choose the portion to focus on at each specific moment. Thanks!

Your co de seems like it must be running on an
old version of Bokeh.

          Looking at the link you posted, it seems to

me that you want to do someth ing
very similar to the ohl c
ex ample:

                    In particular you want to

set the follow_interval on your x_range

p.x_range.follow = “end”

                      p.x_range.follow_interval = 100

                      p.x_range.range_padding = 0

Hope that helps.

Sincerely,

Sarah Bird

···

https://github.com/bokeh/bokeh/tree/master/examples/app/ohlchttps://github.com/bokeh/bokeh/blob/master/examples/app/ohlc/main.py#L17-L20
On 8/12/16 12:20 PM, Mike Yin wrote:

    Hey, I wrote the following program that basically

updates a graph with a random new value as time passes.

import time

import random

from random import shuffle

        from bokeh.plotting import figure, output_server,

cursession, show, Session

        session = Session(root_url='',

load_from_config=False)

session.register(‘anon3’, ‘1234’)

session.login(‘anon’, ‘1234’)

output_server(“animated_line”)

a = random.random()*10

b = random.random()*10

p = figure(plot_width=1000, plot_height=600)

p.xaxis.bounds = (1,100)

p.line([0], [a], name=‘ex_line1’)

p.line([0], [b], name=‘ex_line2’)

show§

renderer1 = p.select(dict(name=“ex_line1”))

ds1 = renderer1[0].data_source

renderer2 = p.select(dict(name=“ex_line2”))

ds2 = renderer2[0].data_source

i = 0

while True:

a1 = random.random()*10

b1 = random.random()*10

ds1.data[“x”].append(i)

ds2.data[“x”].append(i)

ds1.data[“y”].append(a1)

cursession().store_objects(ds1)

cursession().store_objects(ds2)

time.sleep(0)

i+= 1

        The problem is that the axes sorta squish up as the values

begin to get large (as shown
here: )
I was wondering if there’s a way for us to manually adjust
the window so that we can choose the portion to focus on at
each specific moment. Thanks!

  You received this message because you are subscribed to the Google

Groups “Bokeh Discussion - Public” group.

  To unsubscribe from this group and stop receiving emails from it,

send an email to [email protected].

  To post to this group, send email to [email protected]

  To view this discussion on the web visit [https://groups.google.com/a/continuum.io/d/msgid/bokeh/f820a2f1-6cf0-4e1a-ae07-f0e6e6f2db50%40continuum.io](https://groups.google.com/a/continuum.io/d/msgid/bokeh/f820a2f1-6cf0-4e1a-ae07-f0e6e6f2db50%40continuum.io?utm_medium=email&utm_source=footer).

  For more options, visit [https://groups.google.com/a/continuum.io/d/optout](https://groups.google.com/a/continuum.io/d/optout).


Sarah Bird
Developer, Bokeh

    [
      ![Continuum Analytics](http://docs.continuum.io/_static/img/ContinuumWordmark.png)
    ](http://continuum.io)

http://127.0.0.1:5006/https://gyazo.com/30be6427d6a2308219d9fbf2cb9a25c5