{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "nbsphinx": "hidden"
   },
   "source": [
    "This notebook is part of the `nbsphinx` documentation: https://nbsphinx.readthedocs.io/."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Using Cell Metadata to Select a Thumbnail\n",
    "\n",
    "If the [nbsphinx-thumbnail](cell-tag.ipynb) cell tag is not enough,\n",
    "you can use cell metadata to specify more options.\n",
    "\n",
    "The last cell in this notebook has this metadata:\n",
    "\n",
    "```json\n",
    "{\n",
    "    \"nbsphinx-thumbnail\": {\n",
    "        \"tooltip\": \"This tooltip message was defined in cell metadata\"\n",
    "    }\n",
    "}\n",
    "```\n",
    "\n",
    "If there are multiple outputs in the selected cell,\n",
    "the last one is used.\n",
    "See [Choosing from Multiple Outputs](multiple-outputs.ipynb)\n",
    "for how to select a specific output."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "plt.rcParams['image.cmap'] = 'coolwarm'\n",
    "plt.rcParams['image.origin'] = 'lower'"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Some example data stolen from\n",
    "https://matplotlib.org/examples/pylab_examples/pcolor_demo.html:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "x, y = np.meshgrid(np.arange(-3, 3, 0.1), np.arange(-2, 2, 0.1))\n",
    "z = (1 - x / 2 + x ** 5 + y ** 3) * np.exp(-x ** 2 - y ** 2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "zmax = np.max(np.abs(z))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "nbsphinx-thumbnail": {
     "tooltip": "This tooltip message was defined in cell metadata"
    }
   },
   "outputs": [],
   "source": [
    "fig, ax = plt.subplots(figsize=[5, 3.5])\n",
    "ax.imshow(z, vmin=-zmax, vmax=zmax)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
