{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Quiver Plot"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Figure size 640x480 with 3 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "from matplotlib.animation import PillowWriter\n",
    "import animatplot as amp\n",
    "\n",
    "\n",
    "x = np.linspace(0, 2 * np.pi, 10)\n",
    "y = np.linspace(0, 2 * np.pi, 5)\n",
    "t = np.linspace(0, 4.9, 25)\n",
    "\n",
    "timeline = amp.Timeline(t)\n",
    "\n",
    "X, Y, T = np.meshgrid(x, y, t)\n",
    "\n",
    "U = np.cos(X + T)\n",
    "V = np.sin(Y + T)\n",
    "\n",
    "ax = plt.axes(xlim=[-1, 7], ylim=[-1, 7])\n",
    "block1 = amp.blocks.Quiver(\n",
    "    X[:, :, 0], Y[:, :, 0], U, V, ax=ax, t_axis=2, units=\"inches\", pivot=\"mid\"\n",
    ")\n",
    "anim = amp.Animation([block1], timeline)\n",
    "\n",
    "anim.toggle()\n",
    "anim.timeline_slider()\n",
    "\n",
    "anim.save(\"quiver.gif\", writer=PillowWriter(fps=10))\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "raw",
   "metadata": {
    "raw_mimetype": "text/restructuredtext"
   },
   "source": [
    ".. image:: quiver.gif"
   ]
  }
 ],
 "metadata": {
  "celltoolbar": "Raw Cell Format",
  "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.6.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
