import numpy as np import holoviews as hv from holoviews import dim, opts hv.extension('bokeh') import io try: from urllib2 import urlopen except: from urllib.request import urlopen raw = urlopen('http://assets.holoviews.org/data/mandelbrot.npy').read() array = np.load(io.BytesIO(raw)).astype(np.float16)[::2,::2] dots = np.linspace(-0.45, 0.45, 19) fractal = hv.Image(array) # First example on the old holoviews.org homepage was: # ((fractal * hv.HLine(y=0)).hist() + fractal.sample(y=0)) layouts = {y: (fractal * hv.Points(fractal.sample([(i,y) for i in dots])) + fractal.sample(y=y) + hv.operation.threshold(fractal, level=np.percentile(fractal.sample(y=y)['z'], 90)) + hv.operation.contours(fractal, levels=[np.percentile(fractal.sample(y=y)['z'], 60)])) for y in np.linspace(-0.3, 0.3, 21)} layout = hv.HoloMap(layouts, kdims='Y').collate() layout.opts( opts.Contours(color='w', show_legend=False), opts.Points(size=dim('z')*10)).cols(2)