How to update Holoviews plot's width/height?

Hello everyone, 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 existed 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? 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)

Do you want to stick to only holoviews or panel can be an option?

with panel you could do that:

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)

1 Like

Dear xavArtley, thank you so much for that answer! You’ve just answered more than one question by your post! Lot of thanks!