import numpy as np import holoviews as hv from holoviews import opts hv.extension('bokeh') np.set_printoptions(precision=2, linewidth=80) opts.defaults(opts.Layout(shared_axes=False)) def f(x,y): return x+y/3.1 region=(-0.5,-0.5,0.5,0.5) def coords(bounds,samples): l,b,r,t=bounds hc=0.5/samples return np.meshgrid(np.linspace(l+hc,r-hc,samples), np.linspace(b+hc,t-hc,samples)) f5=f(*coords(region,5)) f5 r5 = hv.Raster(f5, label="R5") i5 = hv.Image( f5, label="I5", bounds=region) h5 = hv.HeatMap([(x, y, round(f5[4-y,x],2)) for x in range(0,5) for y in range(0,5)], label="H5") h5_labels = hv.Labels(h5).opts(padding=0) r5 + i5 + h5*h5_labels "r5[0,1]=%0.2f r5.data[0,1]=%0.2f i5[-0.2,0.4]=%0.2f i5[-0.24,0.37]=%0.2f i5.data[0,1]=%0.2f" % \ (r5[1,0], r5.data[0,1], i5[-0.2,0.4], i5[-0.24,0.37], i5.data[0,1]) f10=f(*coords(region,10)) f10 r10 = hv.Raster(f10, label="R10") i10 = hv.Image(f10, label="I10", bounds=region) r10+i10 "r10[0,1]=%0.2f r10.data[0,1]=%0.2f i10[-0.2,0.4]=%0.2f i10[-0.24,0.37]=%0.2f i10.data[0,1]=%0.2f" % \ (r10[1,0], r10.data[0,1], i10[-0.2,0.4], i10[-0.24,0.37], i10.data[0,1]) sl10=i10[-0.275:0.025,-0.0125:0.2885] sl10.data sl10 r5[0:3,1:3] + r5[0:3,1:2] e10=i10.sample(x=-0.275, y=0.2885) e10.opts(height=75) r10=i10.sample(y=0.2885) r10