{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "URL: http://matplotlib.org/examples/specialty_plots/topographic_hillshading.html\n",
    "\n",
    "Most examples work across multiple plotting backends, this example is also available for:\n",
    "\n",
    "* [Matplotlib - topographic hillshading](../matplotlib/topographic_hillshading.ipynb)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import holoviews as hv\n",
    "hv.extension('bokeh')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Define data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import holoviews as hv\n",
    "import matplotlib.pyplot as plt\n",
    "from matplotlib.cbook import get_sample_data\n",
    "from matplotlib.colors import LightSource\n",
    "\n",
    "dem = np.load(get_sample_data('jacksboro_fault_dem.npz'))\n",
    "z = dem['elevation']\n",
    "\n",
    "dx, dy = dem['dx'], dem['dy']\n",
    "dy = 111200 * dy\n",
    "dx = 111200 * dx * np.cos(np.radians(dem['ymin']))\n",
    "\n",
    "# Shade from the northwest, with the sun 45 degrees from horizontal\n",
    "ls = LightSource(azdeg=315, altdeg=45)\n",
    "cmap = plt.cm.gist_earth\n",
    "\n",
    "# Vary vertical exaggeration and blend mode and plot all combinations\n",
    "grid = hv.GridMatrix(kdims=['Vertical exaggeration', 'Blend mode', ])\n",
    "for ve in [0.1, 1, 10]:\n",
    "    # Show the hillshade intensity image in the first row\n",
    "    grid['None', ve] = hv.Image(ls.hillshade(z, vert_exag=ve, dx=dx, dy=dy))\n",
    "    # Place hillshaded plots with different blend modes in the rest of the rows\n",
    "    for mode in ['hsv', 'overlay', 'soft']:\n",
    "        rgb = ls.shade(z, cmap=cmap, blend_mode=mode,\n",
    "                       vert_exag=ve, dx=dx, dy=dy)\n",
    "        grid[mode, ve] = hv.RGB(rgb)\n",
    "        \n",
    "opts = {'GridMatrix': {'plot': dict(xaxis='bottom', shared_xaxis=False, shared_yaxis=False,\n",
    "                                    yaxis='left', bgcolor='white')},\n",
    "       'Image': {'style': dict(cmap='gray')}}"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Plot"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "grid(opts)"
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python",
   "pygments_lexer": "ipython3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
