I have quite a complicated DynamicMap in Holoviews with the call function returning a Layout Object of Multiple Overlays. The structure is basically like this:
Dynamic Map → Layout (2 Columns of 9 Overlays) → Overlay from 8-9 Curves.
I want to rasterize this DynamicMap but don’t know how to start. I tried rasterize(DynamicMap) but it returned
My code is roughly currently like this:
def plot_curve(dropdown1_value, dropdown2_value, dropdown3_value):
if df_res.empty:
return hv.Layout([self.null_graph(year) for year in years].append(self.null_graph('2015-2022'))).cols(2)
else:
year_plots = []
for year in years:
df_year = df_res[df_res['year']==year]
year_plots.append(self.build_year_plot(data=df_year, title=f"{self.site_name}, {year}", legend_args= self.legend, min_freq=min_freq, max_freq=max_freq))
year_plots.append(self.build_year_plot(data=df_res, title=f"{self.site_name}, 2015-2022",legend_args=self.legend, min_freq=min_freq, max_freq=max_freq))
return hv.Layout(year_plots).cols(2)
dmap = hv.DynamicMap(plot_curve, kdims=["dropdown1", "dropdown2", "dropdown3"])
dmap = dmap.redim.values(dropdown1=dropdown1_items.keys(), dropdown2=dropdown2_items.keys(), dropdown3=dropdown3_items).redim(dropdown1 = dropdown1_name, dropdown2 = dropdown2_name, dropdown3=dropdown3_name)
return dmap
and build_year_plot is roughly like this
list_of_curves = list()
# build curves and shaded areas from subdata
for label, group, legend_color in zip(legend_args[0].keys(), groupedDict.values(), legend_args[1]):
curve = hv.Curve(
data,
kdims='frequency',
vdims='mean',
).opts(...)
std_area = hv.Area(
data,
kdims='frequency',
vdims=['lb', 'ub']
).opts(...)
list_of_curves.append(curve*std_area)
# build overlay
return hv.Overlay(list_of_curves).opts(
height=400,
width=600,
...)