Mandelbrot section

Most examples work across multiple plotting backends, this example is also available for:

HoloViews demo that used to be showcased on the [

In [1]:
import numpy as np
import holoviews as hv

Load the data

In [2]:
import io
try:    from urllib2 import urlopen
except: from urllib.request import urlopen

raw = urlopen('').read()
array = np.load(io.BytesIO(raw)).astype(np.float32)


In [3]:
%%opts Points [scaling_factor=50] Contours [show_legend=False] (color='w')
dots = np.linspace(-0.45, 0.45, 19)
fractal = hv.Image(array)
# First example on the old 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)}

hv.HoloMap(layouts, kdims=['Y']).collate().cols(2)

Download this notebook from GitHub (right-click to download).