Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a method to "reset" a figure #5071

Closed
swevrywhere opened this issue Sep 1, 2016 · 11 comments
Closed

Add a method to "reset" a figure #5071

swevrywhere opened this issue Sep 1, 2016 · 11 comments

Comments

@swevrywhere
Copy link

@swevrywhere swevrywhere commented Sep 1, 2016

I want the ability to reset a figure via code in the same way as the figure reset tool.

I asked a related question on Stack Overflow, and it was recommended that I open an issue to track the request.

http://stackoverflow.com/questions/39278110/whats-the-command-to-reset-a-bokeh-plot

@birdsarah birdsarah added this to the short-term milestone Sep 2, 2016
@markjay4k
Copy link

@markjay4k markjay4k commented Jun 27, 2017

I would like the same.

Looking for a way to easily clear a bokeh figure

@ross8711
Copy link

@ross8711 ross8711 commented Jul 14, 2017

I also would need way of doing this.

@uweschmitt
Copy link

@uweschmitt uweschmitt commented Jul 24, 2017

Would also need this.

@nanodan
Copy link

@nanodan nanodan commented Oct 19, 2017

Also need this.

@pchavanne
Copy link

@pchavanne pchavanne commented Dec 12, 2017

Would need this too.

@Milly
Copy link

@Milly Milly commented Dec 13, 2017

Need this.

@malewick
Copy link

@malewick malewick commented Feb 12, 2018

Would also need this.

@bryevdv bryevdv modified the milestones: 0.12.x, 0.12.16 Mar 17, 2018
@bryevdv bryevdv mentioned this issue Apr 5, 2018
1 of 1 task complete
@bryevdv
Copy link
Member

@bryevdv bryevdv commented Apr 5, 2018

After #7757 is merged, this 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))
@nathan-vignal
Copy link

@nathan-vignal nathan-vignal commented May 9, 2019

the code given by bryevdv doesn't work, i get this js error "
Uncaught TypeError: Cannot read property 'emit' of undefined at eval (eval at <anonymous> (bokeh-0.12.7.min.js:25), <anonymous>:4:13) at r.execute (bokeh-0.12.7.min.js:25) at e.<anonymous> (bokeh-0.12.7.min.js:22) at t.emit (bokeh-0.12.7.min.js:2) at e.t._setv (bokeh-0.12.7.min.js:1) at e.t.setv (bokeh-0.12.7.min.js:1) at e.set (bokeh-0.12.7.min.js:1) at e.change_input (bokeh-widgets-0.12.7.min.js:1) at e._button_click (bokeh-widgets-0.12.7.min.js:1) at HTMLButtonElement.<anonymous> (bokeh-widgets-0.12.7.min.js:1)
Any idea on how i can reset a figure ?

@bryevdv
Copy link
Member

@bryevdv bryevdv commented May 9, 2019

@nathan-vignal it's the opposite, your version of Bokeh is way too old. This feature landed in 0.12.16 and your output shows 0.12.7

@RainerHeintzmann
Copy link

@RainerHeintzmann RainerHeintzmann commented Apr 29, 2020

If you are in a notebook, the simple solution can be to directly access the renderers in the figure p:

p.renderers[0].visible=False
hides a specific renderer in the figure, whereas

p.renderers = []
would clear all the renderers. Of course you may need to force update of the display. In a notebook by calling:

push_notebook()
I am not sure, how much of a hack this is, but it seems to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.