What is a fast and proper way to refresh/update plots in Bokeh (0.11) server app?

前端 未结 1 1964
清歌不尽
清歌不尽 2021-02-04 03:13

I have a bokeh (v0.11) serve app that produces a scatter plot using (x,y) coordinates from a data frame. I want to add interactions such that when a user either selects points o

相关标签:
1条回答
  • 2021-02-04 03:36

    If you are streaming data, then there is a related answer here: Timeseries streaming in bokeh

    If you need update everything at once, then you can do that, and my suggestion is your Strategy 1, which is demonstrated, e.g. here:

    https://github.com/bokeh/bokeh/blob/master/examples/app/sliders.py

    The particular thing to note is that you really have to update all of source.data in one go. One of the assumptions is that all the columns of a column data source always have the same length. Updating individual columns runs the risk of breaking this assumption, which can cause problems. So you want to update all at once, with something like:

    # Generate the new curve
    x = np.linspace(0, 4*np.pi, N)
    y = a*np.sin(k*x + w) + b
    
    source.data = dict(x=x, y=y)
    
    0 讨论(0)
提交回复
热议问题