What's the command to “reset” a bokeh plot?

前端 未结 3 467
生来不讨喜
生来不讨喜 2021-01-04 07:46

I have a bokeh figure that has a reset button in the toolbar. Basically, I want to \"reset\" the figure when I update the data that I\'m plotting in the figure. How can I do

3条回答
  •  一向
    一向 (楼主)
    2021-01-04 08:41

    UPDATE: A PR has been submitted for this feature. After Bokeh 0.12.16 is released, the following will work:

    from bokeh.io import show
    from bokeh.layouts import column
    from bokeh.models import Button, CustomJS
    from bokeh.plotting import figure
    
    p = figure(tools="reset,pan,wheel_zoom,lasso_select")
    p.circle(list(range(10)), list(range(10)))
    
    b = Button()
    b.js_on_click(CustomJS(args=dict(p=p), code="""
        p.reset.emit()
    """))
    
    show(column(p, b))
    

    As of Bokeh 0.12.1 there is no built in function to do this. It would possible to make a custom extension that does this. However, that would take a little work and experimentation and dialogue. If you'd like to pursue that option, I'd encourage you to come to the public mailing list which is better suited to iterative collaboration and discussion than SO. Alternatively, please feel free to open a feature request on the project issue tracker

提交回复
热议问题