18

I want to plot a live time series in bokeh. I want to plot only the new data points at each update. How can I do this ?

There is an example on the bokeh website for animated plots but it involves redrawing the whole picture every time. Also I am looking for a simple example where I can do a live plot of a time series point by point.

4

1 回答 1

13

从 Bokeh0.11.1开始,Bokeh 服务器应用程序中的列数据源现在有了一个流接口。您可以在此处查看并轻松运行示例:

https://github.com/bokeh/bokeh/tree/master/examples/app/ohlc

该示例显示了带有 MACD 指标(基于合成分时数据)的实时更新 OHLC 图表,该图表仅在每次更新时使用最新数据点更新图表。

基本上,使用流接口由两部分组成。首先创建一个dict与列数据源具有相同“形状”的新对象:

new_data = dict(
    time=[t],
    open=[open],
    high=[high],
    low=[low],
    close=[close],
    average=[average],
    color=[color],
)

然后将其传递给该.stream方法,并带有一个可选rollover参数,该参数指定在浏览器中保留多大的缓冲区(早期数据开始被丢弃):

source.stream(new_data, 300)

然后,只会将少量数据new_data发送到情节,而不是全部。

于 2016-05-12T11:21:50.400 回答