Can holoviews.operation.contour be generalized to work with hv.QuadMesh?

I’d like to plot a contour for a Wavelet Scalogram.
holoviews.operation.contour currently will not work for QuadMesh…

Not sure if it’s the same but, maybe hv.Contours()?

To quote the docs:
Often Contours will be directly computed from an underlying Image, which is made easy using the contours operation.
So unfortunately, no…

One option is to first interpolate the data on a rectangular grid using
scipy.interpolate.griddata for example, and use contours on the output…

this routine would do the trick…

def interpolated_quadmesh( x,y, d, method='nearest'):
    from scipy.interpolate import griddata
    xi,yi = np.meshgrid(np.linspace(np.min(x), np.max(x), len(x)),
                        np.linspace(np.min(y), np.max(y), len(y)))
    di = griddata( (x.ravel(), y.ravel()), d.ravel(), (xi.ravel(), yi.ravel()), method=method )
    return xi,yi, di.reshape(d.shape)