Search code examples
pythonbokehheatmapholoviews

HoloViews create interpolated colorful heatmap


I have created a heatmap using holoviews on top of bokeh

import numpy as np
import pandas as pd
import holoviews as hv
from holoviews import opts
hv.extension('bokeh')

df = pd.DataFrame(np.random.rand(10, 10) * 100)
heatmap = hv.HeatMap((df.columns, df.index, df))
heatmap.opts(width=500, title='Thermal map', colorbar=True, tools=['hover'], cmap='Turbo')

and got the following heatmap:

enter image description here

How can I make the heatmap color interpolate same as the colorbar

Like moving from pixel to pixel as a gradient

similar to:

enter image description here

Thanks!!


Solution

  • Relying on post comments I was able to interpolate heatmap, especially James A. Bednar comment.

    import holoviews as hv
    from holoviews import opts
    from holoviews.operation.datashader import regrid
    df = pd.DataFrame(np.random.rand(10, 10) * 100)
    img = hv.Image((df.columns, df.index, df))
    img.opts(width=500, height=500, title='Thermal map', cmap='RdYlBu_r' ,tools['hover'], colorbar=True)
    inter_img = regrid(img, upsample=True, interpolation='bilinear')
    img + inter_img
    

    enter image description here

    Thanks so much