Support reactive expressions in arguments and options
Software version info
holoviews : 1.18.3
bokeh : 3.3.4 colorcet : 3.0.1 dask : 2023.6.0 datashader : 0.16.0 geoviews : 1.11.0 hvplot : 0.9.2 IPython : 8.15.0 jupyterlab : 4.0.11 matplotlib : 3.8.0 notebook : 7.0.6 numba : 0.58.0 numpy : 1.24.3 pandas : 2.1.1 panel : 1.3.1 param : 2.0.1 pillow : 10.0.1 pyarrow : 11.0.0 pyviz_comms : 2.3.0 scipy : 1.11.3 spatialpandas : 0.4.9 xarray : 2023.6.0
I would expect reactive expressions (pn.rx(), param.rx()) to be treated the same as Panel Widgets and Param Parameters (i.e., support for all Reactive References), but only widgets and parameters seem to be accepted:
import hvplot.pandas, pandas as pd, panel as pn
df = pd.DataFrame([6,2,9], [1,2,3])
e = pn.widgets.IntSlider(value=2, start=1, end=10, name="e")
pn.Column(e,df.hvplot.line(line_width=e))
pn.Column(e,df.hvplot.line(line_width=e.param.value))
pn.Column(e,df.hvplot.line(line_width=e.rx()))
AbbreviatedException: TypeError: __str__ returned non-string (type rx)
For completeness, note that .apply.opts() can also be used successfully here:
import hvplot.pandas, pandas as pd, panel as pn
df = pd.DataFrame([6,2,9], [1,2,3])
e = pn.widgets.IntSlider(value=2, start=1, end=10, name="e")
pn.Column(e, df.hvplot.line().apply.opts(line_width=e))
Taking the initial example, we can see the object returned is not a HoloViews element but a Panel object:
I think we weren't very happy with non-HoloViews objects returned by .hvplot() calls (there might be an issue on that topic). I also have some vague memory of us talking about deprecating some of that functionality, since it can be done with .interactive():
It seems to me this issue is part of the greater issue of figuring out what to do with .interactive() now param.rx exists that I put on hvPlot roadmap's for this year. Cc'ing @philippjfr since he may have some ideas 🙃
Taking the initial example, we can see the object returned is not a HoloViews element but a Panel object:
This was an exceptionally bad decision on my part and should be undone. I'm not sure how to undo it cleanly though.
should be undone
Returning a Panel object, or allowing .hvplot() to accept widgets/parameters?
Returning a Panel objects; eventually we do want to accepts reactive references and then apply them with .apply.opts().
Ok, noted.
I'm not sure how to undo it cleanly though.
Perhaps with starting to emit a deprecation warning for the current behavior, and add a parameter (maybe global) for users to opt in the new behavior.