Holoviews/Bokeh Radial Heatmap with various cmap
After insisting (following @James comment) I found how to overlay HeatMaps whithout masking the ones underneath. So I had to overlay N+1 HeatMaps :
- N for the color maps (with
clipping_colors={'NaN':'#00000000'}
to enable transparency) - 1 last one completly transparent (
cmap=['#00000000']
) to manage the tooltips with all the numeric data (tools=['hover']
).
Here is the code :
# Set options common to all HeatMaps
opts.defaults(opts.HeatMap(radial=True, width=800, height=800, hooks=[hook], xmarks=[sum([len(d.criteria) for d in data[:i]]) for i in range(len(data))], ymarks=0, xticks=None, yticks=None))
all_heatmaps = None
# Loop through data (a cmap for each data set)
for d in data:
# Copy global df and only keep values from this data set
sub_df = df.copy()
sub_df.loc[~df['Criterion'].isin(d.criteria), 'Value'] = np.nan
# Create heatmap with cmap from this data set (set all NaN values to transparent)
heatmap = hv.HeatMap(sub_df, ["Criterion", "Factor"])
heatmap.opts(opts.HeatMap(cmap=d.cmap, clipping_colors={"NaN": '#00000000'}))
all_heatmaps = all_heatmaps * heatmap if all_heatmaps else heatmap
# Create final HeatMap fully transparent to manage data tooltips
heatmap = hv.HeatMap(df, ["Criterion", "Factor"])
heatmap.opts(opts.HeatMap(cmap=['#00000000'], tools=['hover']))
all_heatmaps *= heatmap