holoviz / holoviews

With Holoviews, your data visualizes itself.
https://holoviews.org
BSD 3-Clause "New" or "Revised" License
2.69k stars 402 forks source link

Composing plot with `param.rx` and `holoviews.Overlay/Layout` #6325

Open LecrisUT opened 1 month ago

LecrisUT commented 1 month ago

I was trying to mix the param.rx and the holoviews composing, but I couldn't manage to get them to work. A mock of the things I was trying to achieve

def plot_curve(data: param.rx) -> param.rx:
    ...
overlay = holoviews.Overlay()
# overlay = param.rx(holoviews.Overlay)
overlay *= plot_curve(data1)
overlay *= plot_curve(data2)

But then I encountered errors like:

TypeError: unsupported operand type(s) for *: 'ParameterizedMetaclass' and 'Curve'

What I suspect is a working approach is to encapsulate all of the overlay/layout building in a function such that only the original data types are passed into it, and at the very end there is a final param.rx of the overlay/layout from which I can compose the final view. How should we expect to combine param.rx and holoviews composition?

philippjfr commented 1 month ago

I think the problem is that HoloViews intercepts the __mul__ and __rmul__ operations. So we may just have to delegate it to rx inside the HoloViews method(s).

LecrisUT commented 1 month ago

I did make some progress by making sure overlay is also a param.rx, but there are a lot of pitfalls down the line with doing so. Ideally only the Cruve objects should be param.rx types