I would like to link selections across several elements, one of which is actually a 'Overlay' (typically plot1*plot2
). However, I have not been able to make it work.
Indeed, after being initialized link_selections is set by passing as an argument a layout that contains elements sharing the same Dataset. For instance, looking at the example provided by Holoviews in the user guide:
w_accel_scatter = hv.Scatter(autompg_ds, 'weight', 'accel')
mpg_hist = histogram(autompg_ds, dimension='mpg', normed=False).opts(color="green")
violin = hv.Violin(autompg_ds, [], 'hp')
mpg_ls = link_selections.instance()
mpg_ls(w_accel_scatter + mpg_hist + violin)
In my case I would like to display, say, w_accel_scatter*line_plot + mpg_hist + violin
(with line_plot
using other data), while retaining the selection link between w_accel_scatter
, mpg_hist
and violin
:
The problem is that calling mpg_ls()
actually triggers the display of what is passed as an argument and obviously mpg_ls(w_accel_scatter*other_plot + mpg_hist + violin)
won't work.
Btw I am working within a notebook and using the bokeh backend. Any help would be appreciated!
I'm not sure what you mean by "
calling mpg_ls() actually triggers the display of what is passed as an argument
". Returning an object as the value of a cell is what triggers the display, not mpg_ls, so you should be able to keep working after your mpg_ls call. You just need to capture the result of your mpg_ls call, and then you can work with it until you eventually have something you want to display.In any case, because nothing should be displayed immediately when you do
mpg_ls()
, you can pass each object you want linked tompg_ls
independently, linking each of the ones you want to link, then put them all into whatever overlay or layout you want.ETA an example of doing precisely that:
Here we specifically link only those plots that are related to each other, and not the unrelated
other_plot
. We should clarify how to do this in the docs, because it's not obvious! Also, I would have expectedmpg_ls(w_accel_scatter*other_plot + mpg_hist + violin)
to work, which I'll file as an issue on HoloViews.