1

I would like to work in Jupyter Notebook though the project with one plot. Update it with a new data or new layout, maybe add/delete additional plot nearby it and so on… In Bokeh I could use smth similar to:

 target = show(layout, notebook_handle=True)
 push_notebook(handle=target) 

In Holoviews I found how to feed new data to the existing plot:

pipe = Pipe(data=[])
Image = hv.DynamicMap(hv.Image, streams=[pipe1])
pipe.send(np.random.rand(3,2)) #data change

But is there any solution to manage live layout update in Holoviews? Is it possible to update existed plot by .opts() construction? In this example I will get a new plot:

pipe = Pipe(data=[])
Image = hv.DynamicMap(hv.Image, streams=[pipe])
Image.opts(width=1000,height=1000)
#######new cell in jupyter notebook############
Image.opts(width=100,height=100)

1 Answer 1

2

Here is a brilliant answer I have got on my question:

import param
import panel as pn
import numpy as np
import holoviews as hv
from holoviews.streams import Pipe
pn.extension()
pipe = Pipe(data=[])

class Layout(param.Parameterized):
    colormap = param.ObjectSelector(default='viridis', objects=['viridis', 'fire'])
    width = param.Integer(default=500)
    update_data = param.Action(lambda x: x.param.trigger('update_data'), label='Update data!')
    
    @param.depends("update_data", watch=True)
    def _update_data(self):
        pipe.send(np.random.rand(3,2))

layout = Layout()
Image = hv.DynamicMap(hv.Image, streams=[pipe]).apply.opts(cmap=layout.param.colormap, width=layout.width)
pdmap = pn.panel(Image)
playout = pn.panel(layout)
def update_width(*events):
    for event in events:
        if event.what == "value":
            pdmap.width = event.new
layout.param.watch(update_width, parameter_names=['width'], onlychanged=False)

pn.Row(playout, pdmap)

https://discourse.holoviz.org/t/how-to-update-holoviews-plots-width-height/1947

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.