Mandelbrot Section#

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


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

HoloViews demo that used to be showcased on the [holoviews.org

import numpy as np
import holoviews as hv
from holoviews import dim, opts
hv.extension('bokeh')

Load the data#

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]

Plot#

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)
This web page was generated from a Jupyter notebook and not all interactivity will work on this website. Right click to download and run locally for full Python-backed interactivity.

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