Hi. Panel needs to receive a Matplotlib Figure object. C.f. Matplotlib β Panel.
Very often functions that plot via Matplotlib accept an ax argument where you can then provide the Matplotlib Axes object to plot on. You can create the Axes from the Figure object as shown below.
import statsmodels.api as sm
import numpy as np
from matplotlib.figure import Figure
from matplotlib import cm
def qqplot(data, line):
fig = Figure(figsize=(8, 6))
ax = fig.subplots()
sm.qqplot(data, line=line, ax=ax)
return fig
data = np.random.normal(0, 1, 100)
import panel as pn
pn.extension(sizing_mode="stretch_width", design="bootstrap")
line = pn.widgets.Select(name="Line", value="45", options=["45", "s", "r", "q", None])
plot = pn.bind(qqplot, line=line, data=data)
pn.Column(
line,
pn.pane.Matplotlib(plot, tight=True, format="svg"),
max_width=800,
).servable()
The plot does not react to changes in the toggles. I get the following warning as well:
WARNING:param.ParamFunction01034: The function 'qqplot' does not have any dependencies and will never update. Are you sure you did not intend to depend on or bind a parameter or widget to this function? If not simply call the function before passing it to Panel. Otherwise, when passing a parameter as an argument, ensure you pass at least one parameter and reference the actual parameter object not the current value, i.e. use object.param.parameter not object.parameter