0

I want to create a plot that shows the live metering data I am getting from an electricity meter.

I already figured out how to have a plot in bokeh, that updates every x seconds with new values, but now I want to have the new values always be at a fixed point in the plot, while the range of the axis does not increase. I fixed the range by adding x_range=[0, 10] to the figure, however that plot is running out of the screen and I have to manually follow it. How do I change it so it follows it automatically?

Is that even possible in bokeh or should I be using something different for my project?

Ale Pan
  • 57
  • 1
  • 6

1 Answers1

0

Use a default DataRange1d range (i.e. do not set the range to a fixed interval) and then set the follow property on the range. You can also set follow_interval to specify how far back the range should trail the latests data.

p.x_range.follow = "end"
p.x_range.follow_interval = 100

For a complete demonstration see the OHLC ticker example.

bigreddot
  • 33,642
  • 5
  • 69
  • 122
  • Thank you very much! Do you by any chance know how I can connect to my bokeh server through another browser on a different machine in the same network? – Ale Pan Jul 03 '20 at 08:58
  • If you are just connecting to the Bokeh server directly then it should just work to use the ip address. If you have a hostname set up or are embedding the bokeh server in some other site you will need to start the bokeh server with the `--allow-websocket-orgin` option to allow connections from those origins. If there are still issues, a new topic with debug information (browser js logs, server console logs) is appropriate. – bigreddot Jul 03 '20 at 17:32
  • So I tried just starting the server on my laptop through command line, then found out my IP via a google search and then tried to enter the IP:5006/BokehServer (which is my script name) on my phone, however that just gave me the error: Cannot open page because it could not connect to the server. – Ale Pan Jul 04 '20 at 09:26
  • Please open a separate new question, here or on the project Discourse https://discourse.bokeh.org/ – bigreddot Jul 04 '20 at 18:42