push_notebook() does not work with ipywidgets Output Widget
See original GitHub issueRuntime Info:
notebook server is 5.0.0 Python 3.6.1 |Continuum Analytics, Inc.| (default, May 11 2017, 13:09:58) IPython 6.0.0 bokeh ‘0.12.9’ ipywidgets ‘7.0.1’ ubuntu 16
I am trying to embed bokeh plots within the ipywidgets ecosystem. However, I cannot update these plots externally when they are wrapped in an ipywidget Output Widget . Here is a simple repro
This displays the blank graph:
import bokeh
from bokeh.io import output_notebook, show, push_notebook
output_notebook(bokeh.resources.INLINE)
from bokeh.models import ColumnDataSource, Circle
import ipywidgets as widgets
from IPython.display import display
plot = figure()
source = ColumnDataSource(
data=dict(
x=[],
y=[],
)
)
circle = Circle(x="x", y="y", size=15, fill_color="blue", fill_alpha=0.8, line_color=None)
plot.add_glyph(source, circle)
outw = widgets.Output()
with outw:
h = show(plot, notebook_handle=True)
display(outw)
This cell should update that graph:
source.data = {'x':[0], 'y':[0]}
push_notebook(handle=h);
However the first graph does not change. If I remove the wrapping in the output widget it does update. If i use an ipywidget (instead of a bokeh plot) inside of the output widget it updates as expected.
Issue Analytics
- State:
- Created 6 years ago
- Comments:12 (5 by maintainers)
Top Results From Across the Web
Output widgets: leveraging Jupyter's display system - ipywidgets
The Output widget can capture and display stdout, stderr and rich output ... works well for understanding and debugging single callbacks, it does...
Read more >Using with Jupyter — Bokeh 2.4.3 Documentation
You can use this handle object with the push_notebook() function to update the plot with any recent changes to plots properties, data source...
Read more >IPython Notebook ipywidgets does not show - Stack Overflow
The code seem to run just fine, as the table appears, but the slide bar just doesn't appear. I didn't change my code...
Read more >How to use ipywidgets to make your Jupyter notebook ...
Jupyter widgets can make notebooks be more interactive and make data exploration much easier, especially for end users who are not coders.
Read more >ipywidgets | Databricks on AWS
A notebook using ipywidgets must be attached to a running cluster. Widget states are not preserved across notebook sessions. You must re-run ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Here is a full example of how to use a bokeh plot inside of a Jupyter ipywidget hierarchy:
Hi,
I just ran into the same problem and I found a workaround: you need to render the widgets before plotting into it! This code works for me:
Now you can update the plot:
Edit and FYI: this is the same for matplotlib plots as well