I have been successfully using hvplot, holoviews and panel to make some interactive plots in a Jupyter Lab notebook, but I am having troubles when exporting to html.
I am using:
panel 0.13.1
holoviews 1.14.9
If I create a single chart that responds to a widget and export it to html, then all works fine and the chart updates when I change the widget selection. However, if I include more than one plot, then neither plot updates in the resulting html. Is this a known issue, or perhaps there is something else I need to do when there is more than one chart?
As an example, I am using some demo code I found in the panel or holoviews documentation, which is as follows:
import pandas as pd
import numpy as np
import panel as pn
pn.extension(sizing_mode="stretch_width")
import holoviews as hv
import hvplot.pandas # noqa: API import
hv.extension("bokeh")
from bokeh.sampledata.iris import flowers
x = pn.widgets.Select(name="x", options=["sepal_width", "petal_width"])
y = pn.widgets.Select(name="y", options=["sepal_length", "petal_length"])
by_species = pn.widgets.Checkbox(name="By species")
color = pn.widgets.ColorPicker(value="#ff0000")
@pn.depends(by_species, color)
def by_species_fn(by_species, color):
return "species" if by_species else color
plot1 = flowers.hvplot(
x=x, y=y, kind="scatter", c=by_species_fn, colorbar=False, width=600, legend="top_right"
)
plot2 = flowers.hvplot(
x=x, y=y, kind="bivariate", c=by_species_fn, colorbar=True, width=600, legend="top_right"
)
flower_page = pn.Row(pn.WidgetBox(x, y, color, by_species), plot1, plot2)
flower_page
This creates a panel with 2 plots and some widgets. In the notebook they both respond to the widgets.
If I create an html output with 1 plot like this:
flower_page = pn.Row(pn.WidgetBox(x, y, color, by_species), plot1)
flower_page.save("flower_page.html", embed=True)
then all is fine and the plot responds in the html page (although the color picker doesn’t seem to affect it).
However, if I create the html with both plots:
flower_page = pn.Row(pn.WidgetBox(x, y, color, by_species), plot1, plot2)
flower_page.save("flower_page.html", embed=True)
then I find that neither plot responds in the final output.
Am I doing something wrong?