I have a Histogram in a DynamicMap whose bounds can change significantly based on widget selections. Here is a small example:
import holoviews as hv
import numpy as np
import panel as pn
hv.extension("bokeh")
def plot_hist(
negpos: str = "positive",
):
data = np.random.normal(size=100)
match negpos:
case "negative":
data = data[data < 0]
# xlim=(min(data),0)
case "positive":
data = data[data > 0]
# xlim=(0, max(data))
counts, edges = np.histogram(data)
hist = hv.Histogram((counts,edges)).opts(
apply_ranges=True,
# xlim=xlim,
)
return hist
negpos_selector = pn.widgets.RadioButtonGroup(
name="negpos",
options=["negative", "positive"]
)
widgets = pn.WidgetBox(negpos_selector)
dmap = hv.DynamicMap(
pn.bind(plot_hist, negpos=negpos_selector)
)
pn.Row(dmap, widgets)
The initial bounds are determined by the data for the initial case, but when I change it, the xlim/ylim bounds do not change to match the data:
, nor does it work if I explicitly set the xlim. Is there some way to force it to update?