{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "Most examples work across multiple plotting backends, this example is also available for:\n", "\n", "* [Matplotlib - mandelbrot section](../matplotlib/mandelbrot_section.ipynb)\n", "\n", "HoloViews demo that used to be showcased on the [holoviews.org" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "import holoviews as hv\n", "from holoviews import dim, opts\n", "hv.extension('bokeh')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Load the data" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import io\n", "try: from urllib2 import urlopen\n", "except: from urllib.request import urlopen\n", "\n", "raw = urlopen('http://assets.holoviews.org/data/mandelbrot.npy').read()\n", "array = np.load(io.BytesIO(raw)).astype(np.float16)[::2,::2]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Plot" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "dots = np.linspace(-0.45, 0.45, 19)\n", "fractal = hv.Image(array)\n", "\n", "# First example on the old holoviews.org homepage was:\n", "# ((fractal * hv.HLine(y=0)).hist() + fractal.sample(y=0))\n", "layouts = {y: (fractal * hv.Points(fractal.sample([(i,y) for i in dots])) +\n", " fractal.sample(y=y) +\n", " hv.operation.threshold(fractal, level=np.percentile(fractal.sample(y=y)['z'], 90)) +\n", " hv.operation.contours(fractal, levels=[np.percentile(fractal.sample(y=y)['z'], 60)]))\n", " for y in np.linspace(-0.3, 0.3, 21)}\n", "\n", "layout = hv.HoloMap(layouts, kdims='Y').collate()\n", "\n", "layout.opts(\n", " opts.Contours(color='w', show_legend=False),\n", " opts.Points(size=dim('z')*10)).cols(2)" ] } ], "metadata": { "language_info": { "name": "python", "pygments_lexer": "ipython3" } }, "nbformat": 4, "nbformat_minor": 2 }