定义一个显示散景图中接下来的 n 个点的更新函数

Define an update function that shows the next n points in the bokeh graph

谁能帮我定义一个关于如何转到散景图中的下一个 n 的函数

toggle_next = Toggle(label='Toggle Next', button_type='success')

def update_next():
"""This function shows the next 10 points in the data"""


toggle_next.on_click(update_next)

你可以只更改 x_range:

from bokeh.plotting import figure
from bokeh.io import show, output_notebook
from bokeh.models import Button, CustomJS
from bokeh.layouts import row
from random import random

p = figure(x_range=(0, 10))
p.line(list(range(1000)), [random() for _ in range(1000)])

b = Button(label='Show next 10', callback=CustomJS(args=dict(xr=p.x_range), code="""
    xr.start = xr.end;
    xr.end = xr.end + 10;
"""))