Setting additional options when layout is generated

I found that when generating a violin plot, some options can only be specified through .opts() rather than in the violin call, e.g.:

cost_plot = df.hvplot.violin(
    y="solution_cost",
    by="solver",
    color="solver",
    aspect=2.5,
    grid=True,
    legend=True,
    groupby=["heuristic", "min_best_path", "moves_per_iter", "add_noise", "round", "weight"],
    widget_location="bottom",
)
cost_plot.opts(
    split="solver",
    inner=None,
    bandwidth=.1,
    violin_width=1.5,
)

But if I try to customize the widget layout or widget classes, then I find that the function returns a Panel layout object instead of the DynamicMap. It is not obvious how to correct set the options in that case.

Is there a recommended way to do this?

That’s a good question. Having to return a Panel object is definitely not ideal, because it mimics the usual HoloViews object without behaving quite the same way, so that’s something we should try to avoid.

Anyway, your code isn’t reproducible, so I can’t try it myself, but I think you can do cost_plot.object.opts(...) instead, to get at the underlying object.

That does work, but if I specific widget_layout, I have to do something like cost_plot[i].object.opts() and that i depends on the particular layout choice.

It would be nice if there were a less hacky way to specify these extra options.

Perhaps file an issue on hvPlot? I imagine we either

  1. get rid of these hvplot → panel layouts
  2. warn about them and offer a way to use opts as kwargs

I vote for option 1, which I think requires providing a way for hvplot to capture the layout info specified by the user and store those declaratively on the holoviews object so that later, when the object is rendered by panel, Panel follows those embedded hints. I think we should be shooting for hvplot to have a single, unified return type of object in all cases, so that users don’t have to figure out the corner cases like this.

Can bump this again: