{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Heatmap Slicer"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "%matplotlib widget\n",
    "import matplotlib.pyplot as plt\n",
    "import numpy as np\n",
    "\n",
    "from mpl_interactions import heatmap_slicer"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Comparing heatmaps\n",
    "\n",
    "Sometimes I find myself wanting to compare horizontal or vertical slices across two different heatmaps with the same shape. The function {func}`.heatmap_slicer` makes this easy and should work for any number of heatmaps from 1 to many (likely not all the way $\\infty$ though). \n",
    "\n",
    "The most important options to play with are:\n",
    "- `slices`: `\"both\"`, `\"vertical\"`, or `\"horizontal\"`\n",
    "- `interaction_type`: `\"move\"` or `\"click\"`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "tags": [
     "remove-output"
    ]
   },
   "outputs": [],
   "source": [
    "x = np.linspace(0, np.pi, 100)\n",
    "y = np.linspace(0, 10, 200)\n",
    "X, Y = np.meshgrid(x, y)\n",
    "data1 = np.sin(X) + np.exp(np.cos(Y))\n",
    "data2 = np.cos(X) + np.exp(np.sin(Y))\n",
    "fig, axes = heatmap_slicer(\n",
    "    x,\n",
    "    y,\n",
    "    (data1, data2),\n",
    "    slices=\"both\",\n",
    "    heatmap_names=(\"dataset 1\", \"dataset 2\"),\n",
    "    labels=(\"Some wild X variable\", \"Y axis\"),\n",
    "    interaction_type=\"move\",\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "![](../_static/images/tight-layout-heatmap-slicer.gif)"
   ]
  }
 ],
 "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.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
