{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "ed32db54",
   "metadata": {},
   "source": [
    "# Animations\n",
    "\n",
    "This page lists the different animations that can be applied to plot objects. All animations share the following parameters:\n",
    "- `duration`: the number of frames the animation runs from.\n",
    "- `delay`(optional): the number of frames after what the animation starts playing.\n",
    "- `easing`(optional): the easing used for this animation ({doc}`See Easings <easings>`). If `None`, a linear easing is applied.\n",
    "\n",
    "Once animations have been set on plot objects, they have to be rendered via `Timeline.animate(plot_objs)` ([See Timeline](timeline)).\n",
    "\n",
    "## Animations of plot objects"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e6cc363d",
   "metadata": {},
   "source": [
    "### Translate\n",
    "\n",
    "```{eval-rst}\n",
    ".. automethod:: diplotocus.animations.Animation.translate\n",
    "    :noindex:\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "8292940a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "e81b7a3356ae4f16a27fae17363df670",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "  0%|          | 0/60 [00:00<?, ?it/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/markdown": [
       "Saved video ../_static/anim_translate.mp4"
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "\n",
       "                <video width=\"640\" height=\"360\" autoplay loop muted playsinline>\n",
       "                <source src=\"../_static/anim_translate.mp4?randId=449\" type=\"video/mp4\">\n",
       "                </video>\n",
       "            "
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "import diplotocus as dpl\n",
    "\n",
    "x = [-1,1,1,-1,-1]\n",
    "y = [-1,-1,1,1,-1]\n",
    "\n",
    "tl = dpl.Timeline(xlim=(-2.5,2.5),ylim=(-2,2))\n",
    "\n",
    "p = dpl.plot(x=x,y=y)\n",
    "p.translate(start_pos=(0,0),end_pos=(1,1),duration=60)\n",
    "\n",
    "tl.animate(p)\n",
    "tl.save_video('../_static/anim_translate.mp4')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "481d9fc4",
   "metadata": {},
   "source": [
    "### Rotate\n",
    "\n",
    "```{eval-rst}\n",
    ".. automethod:: diplotocus.animations.Animation.rotate\n",
    "    :noindex:\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d5870722",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "2985246b2b3d4801a77ae795ad57b4fa",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "  0%|          | 0/60 [00:00<?, ?it/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/markdown": [
       "Saved video ../_static/anim_rotate.mp4"
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "\n",
       "                <video width=\"640\" height=\"360\" autoplay loop muted playsinline>\n",
       "                <source src=\"../_static/anim_rotate.mp4?randId=1017\" type=\"video/mp4\">\n",
       "                </video>\n",
       "            "
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "import diplotocus as dpl\n",
    "\n",
    "x = [-1,1,1,-1,-1]\n",
    "y = [-1,-1,1,1,-1]\n",
    "\n",
    "tl = dpl.Timeline(xlim=(-2.5,2.5),ylim=(-2,2))\n",
    "\n",
    "p = dpl.plot(x=x,y=y)\n",
    "p.rotate(start_angle=20,end_angle=110,duration=60)\n",
    "\n",
    "tl.animate(p)\n",
    "tl.save_video('../_static/anim_rotate.mp4')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "924ff952",
   "metadata": {},
   "source": [
    "### Scale\n",
    "\n",
    "```{eval-rst}\n",
    ".. automethod:: diplotocus.animations.Animation.scale\n",
    "    :noindex:\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f98f41d9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "df72e6522a454ee4808d6091380806a0",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "  0%|          | 0/60 [00:00<?, ?it/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/markdown": [
       "Saved video ../_static/anim_scale.mp4"
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "\n",
       "                <video width=\"640\" height=\"360\" autoplay loop muted playsinline>\n",
       "                <source src=\"../_static/anim_scale.mp4?randId=2110\" type=\"video/mp4\">\n",
       "                </video>\n",
       "            "
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "import diplotocus as dpl\n",
    "\n",
    "x = [-1,1,0,-1]\n",
    "y = [-1,-1,1,-1]\n",
    "\n",
    "tl = dpl.Timeline(xlim=(-2.5,2.5),ylim=(-2,2))\n",
    "\n",
    "p = dpl.plot(x=x,y=y)\n",
    "p.scale(start_scale=(0,1),end_scale=(2,0),duration=60)\n",
    "\n",
    "tl.animate(p)\n",
    "tl.save_video('../_static/anim_scale.mp4')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2084793d",
   "metadata": {},
   "source": [
    "### Tween\n",
    "\n",
    "```{eval-rst}\n",
    ".. automethod:: diplotocus.animations.Animation.tween\n",
    "    :noindex:\n",
    "```\n",
    "\n",
    "```{eval-rst}\n",
    ".. automethod:: diplotocus.animations.Animation.tweens\n",
    "    :noindex:\n",
    "```\n",
    "\n",
    "```{note}\n",
    "\n",
    "`show()` is a shorthand animation that fades in plot objects. It is equivalent to `tween('alpha',0,1)`.\n",
    "\n",
    "`hide()` is a shorthand animation that fades out plot objects. It is equivalent to `tween('alpha',1,0)`.\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "75e7699a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "0b50e0cc3fa14b39a54dd94f405d460d",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "  0%|          | 0/60 [00:00<?, ?it/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/markdown": [
       "Saved video ../_static/anim_tween.mp4"
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "\n",
       "                <video width=\"640\" height=\"360\" autoplay loop muted playsinline>\n",
       "                <source src=\"../_static/anim_tween.mp4?randId=9568\" type=\"video/mp4\">\n",
       "                </video>\n",
       "            "
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "import diplotocus as dpl\n",
    "\n",
    "x = [-1,1,0,-1]\n",
    "y = [-1,-1,1,-1]\n",
    "\n",
    "tl = dpl.Timeline(xlim=(-2.5,2.5),ylim=(-2,2))\n",
    "\n",
    "p = dpl.plot(x=x,y=y)\n",
    "p.tween(property='c',start='red',end='green',duration=60)\n",
    "\n",
    "tl.animate(p)\n",
    "tl.save_video('../_static/anim_tween.mp4')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "25dbbfe4",
   "metadata": {},
   "source": [
    "### Morph\n",
    "\n",
    "```{eval-rst}\n",
    ".. automethod:: diplotocus.animations.Animation.morph\n",
    "    :noindex:\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "0dc03e54",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "4c3e413c90e941c48b44b4b2f828611b",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "  0%|          | 0/60 [00:00<?, ?it/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/markdown": [
       "Saved video ../_static/anim_morph.mp4"
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "\n",
       "                <video width=\"640\" height=\"360\" autoplay loop muted playsinline>\n",
       "                <source src=\"../_static/anim_morph.mp4?randId=1825\" type=\"video/mp4\">\n",
       "                </video>\n",
       "            "
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "import diplotocus as dpl\n",
    "import numpy as np\n",
    "\n",
    "x = np.linspace(0,2*np.pi,60)\n",
    "y = np.cos(x)\n",
    "\n",
    "tl = dpl.Timeline(xlim=(-1,7),ylim=(-2,2))\n",
    "\n",
    "p = dpl.plot(x=x,y=y)\n",
    "\n",
    "x2 = (np.cos(x)+1)*2\n",
    "y2 = np.sin(x)\n",
    "p.morph(new_x=x2,new_y=y2,duration=60)\n",
    "\n",
    "tl.animate(p)\n",
    "tl.save_video('../_static/anim_morph.mp4')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7d3c9b15",
   "metadata": {},
   "source": [
    "### Draw\n",
    "\n",
    "```{eval-rst}\n",
    ".. automethod:: diplotocus.animations.Animation.draw\n",
    "    :noindex:\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a0e5af64",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "800453a5789e4448a9d2937089f1b827",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "  0%|          | 0/60 [00:00<?, ?it/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/markdown": [
       "Saved video ../_static/anim_draw.mp4"
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "\n",
       "                <video width=\"640\" height=\"360\" autoplay loop muted playsinline>\n",
       "                <source src=\"../_static/anim_draw.mp4?randId=6085\" type=\"video/mp4\">\n",
       "                </video>\n",
       "            "
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "import diplotocus as dpl\n",
    "import numpy as np\n",
    "\n",
    "x = np.linspace(0,2*np.pi,60)\n",
    "y = np.cos(x)\n",
    "\n",
    "tl = dpl.Timeline(xlim=(-1,7),ylim=(-2,2))\n",
    "\n",
    "p = dpl.plot(x=x,y=y)\n",
    "p.draw(duration=60)\n",
    "\n",
    "tl.animate(p)\n",
    "tl.save_video('../_static/anim_draw.mp4')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "aff6a20a",
   "metadata": {},
   "source": [
    "### Sequence\n",
    "\n",
    "```{eval-rst}\n",
    ".. automethod:: diplotocus.animations.Animation.sequence\n",
    "    :noindex:\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2e8e28e8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "64ea6e01408440fb8165a65b3870c71b",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "  0%|          | 0/50 [00:00<?, ?it/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/markdown": [
       "Saved video ../_static/anim_sequence.mp4"
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "\n",
       "                <video width=\"640\" height=\"360\" autoplay loop muted playsinline>\n",
       "                <source src=\"../_static/anim_sequence.mp4?randId=1390\" type=\"video/mp4\">\n",
       "                </video>\n",
       "            "
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "import diplotocus as dpl\n",
    "import numpy as np\n",
    "\n",
    "x = np.linspace(0, 2*np.pi, 60)\n",
    "x_rev = x[::-1]\n",
    "xs = np.column_stack((x, x_rev))\n",
    "ys = np.column_stack((np.cos(x), np.sin(x_rev)))\n",
    "\n",
    "tl = dpl.Timeline(xlim=(-1,7),ylim=(-2,2))\n",
    "\n",
    "p = dpl.plot(x=xs,y=ys,lw=0,marker='+',ms=10)\n",
    "p.sequence(duration=50)\n",
    "\n",
    "tl.animate(p)\n",
    "tl.save_video('../_static/anim_sequence.mp4')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "717c6218",
   "metadata": {},
   "source": [
    "## Animations of figures and axes\n",
    "\n",
    "### Axis zoom\n",
    "\n",
    "```{eval-rst}\n",
    ".. automethod:: diplotocus.animations.axis_zoom\n",
    "    :noindex:\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "8bdbdefc",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "bdba23aec1394bb2acb931db6aa4b3e6",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "  0%|          | 0/60 [00:00<?, ?it/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/markdown": [
       "Saved video ../_static/axis_zoom.mp4"
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "\n",
       "                <video width=\"640\" height=\"360\" autoplay loop muted playsinline>\n",
       "                <source src=\"../_static/axis_zoom.mp4?randId=9285\" type=\"video/mp4\">\n",
       "                </video>\n",
       "            "
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "import diplotocus as dpl\n",
    "\n",
    "x = [-1,1,1,-1,-1]\n",
    "y = [-1,-1,1,1,-1]\n",
    "\n",
    "tl = dpl.Timeline(xlim=(-2.5,2.5),ylim=(-2,2))\n",
    "tl.main_axis.plot(x,y)\n",
    "\n",
    "a = dpl.axis_zoom(zoom=2,duration=60)\n",
    "\n",
    "tl.animate(a)\n",
    "tl.save_video('../_static/axis_zoom.mp4')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1089adf5",
   "metadata": {},
   "source": [
    "### Axis limits\n",
    "\n",
    "```{eval-rst}\n",
    ".. automethod:: diplotocus.animations.axis_limits\n",
    "    :noindex:\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e554835f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "c04896d30ed54a9da0965f808223663b",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "  0%|          | 0/60 [00:00<?, ?it/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/markdown": [
       "Saved video ../_static/axis_limits.mp4"
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "\n",
       "                <video width=\"640\" height=\"360\" autoplay loop muted playsinline>\n",
       "                <source src=\"../_static/axis_limits.mp4?randId=2059\" type=\"video/mp4\">\n",
       "                </video>\n",
       "            "
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "import diplotocus as dpl\n",
    "\n",
    "x = [-1,1,1,-1,-1]\n",
    "y = [-1,-1,1,1,-1]\n",
    "\n",
    "tl = dpl.Timeline(xlim=(-2.5,2.5),ylim=(-2,2))\n",
    "tl.main_axis.plot(x,y)\n",
    "\n",
    "a = dpl.axis_limits(xlim=(-5,5),ylim=(-1,1),duration=60)\n",
    "\n",
    "tl.animate(a)\n",
    "tl.save_video('../_static/axis_limits.mp4')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "bc66aa88",
   "metadata": {},
   "source": [
    "### Axis move\n",
    "\n",
    "```{eval-rst}\n",
    ".. automethod:: diplotocus.animations.axis_move\n",
    "    :noindex:\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "694ce676",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "82584be9b320424f8e28f25999647b4b",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "  0%|          | 0/60 [00:00<?, ?it/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/markdown": [
       "Saved video ../_static/axis_move.mp4"
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "\n",
       "                <video width=\"640\" height=\"360\" autoplay loop muted playsinline>\n",
       "                <source src=\"../_static/axis_move.mp4?randId=7288\" type=\"video/mp4\">\n",
       "                </video>\n",
       "            "
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "import diplotocus as dpl\n",
    "\n",
    "x = [-1,1,1,-1,-1]\n",
    "y = [-1,-1,1,1,-1]\n",
    "\n",
    "tl = dpl.Timeline(xlim=(-2.5,2.5),ylim=(-2,2))\n",
    "tl.main_axis.plot(x,y)\n",
    "\n",
    "a = dpl.axis_move(end_pos=(1,1),duration=60)\n",
    "\n",
    "tl.animate(a)\n",
    "tl.save_video('../_static/axis_move.mp4')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "cfc18431",
   "metadata": {},
   "source": [
    "### Axis alpha\n",
    "\n",
    "```{eval-rst}\n",
    ".. automethod:: diplotocus.animations.axis_alpha\n",
    "    :noindex:\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "3187df22",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "d0cb343ba99b4cb2b11d1dc6331ef9e5",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "  0%|          | 0/50 [00:00<?, ?it/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/markdown": [
       "Saved video ../_static/axis_alpha.mp4"
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "\n",
       "                <video width=\"640\" height=\"360\" autoplay loop muted playsinline>\n",
       "                <source src=\"../_static/axis_alpha.mp4?randId=3022\" type=\"video/mp4\">\n",
       "                </video>\n",
       "            "
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "import diplotocus as dpl\n",
    "\n",
    "x = [-1,1,1,-1,-1]\n",
    "y = [-1,-1,1,1,-1]\n",
    "\n",
    "tl = dpl.Timeline(xlim=(-2.5,2.5),ylim=(-2,2))\n",
    "tl.main_axis.plot(x,y)\n",
    "\n",
    "a = dpl.axis_alpha(start_alpha=0,end_alpha=1,duration=50)\n",
    "\n",
    "tl.animate(a)\n",
    "tl.save_video('../_static/axis_alpha.mp4')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3edcfa03",
   "metadata": {},
   "source": [
    "### Figure width ratio\n",
    "\n",
    "```{eval-rst}\n",
    ".. automethod:: diplotocus.animations.fig_width_ratio\n",
    "    :noindex:\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "933f2a37",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "8254dfa9a75346a1ac6bc66df98bf3fc",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "  0%|          | 0/60 [00:00<?, ?it/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/markdown": [
       "Saved video ../_static/fig_width_ratio.mp4"
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "\n",
       "                <video width=\"640\" height=\"360\" autoplay loop muted playsinline>\n",
       "                <source src=\"../_static/fig_width_ratio.mp4?randId=4844\" type=\"video/mp4\">\n",
       "                </video>\n",
       "            "
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "import diplotocus as dpl\n",
    "import matplotlib.pyplot as plt\n",
    "\n",
    "x = [-1,1,1,-1,-1]\n",
    "y = [-1,-1,1,1,-1]\n",
    "\n",
    "fig,ax = plt.subplots(1,2,figsize=(10,5))\n",
    "ax[0].plot(x,y)\n",
    "ax[1].plot(x,y)\n",
    "tl = dpl.Timeline(fig=fig)\n",
    "\n",
    "a = dpl.fig_width_ratio(start_widths=(1,0),end_widths=(0,1),duration=60)\n",
    "\n",
    "tl.animate(a)\n",
    "tl.save_video('../_static/fig_width_ratio.mp4')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d4d77c5f",
   "metadata": {},
   "source": [
    "### Figure height ratio\n",
    "\n",
    "```{eval-rst}\n",
    ".. automethod:: diplotocus.animations.fig_height_ratio\n",
    "    :noindex:\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f2168ae2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "949f933fbfb04ddbbfab89bedb358855",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "  0%|          | 0/60 [00:00<?, ?it/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/markdown": [
       "Saved video ../_static/fig_height_ratio.mp4"
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "\n",
       "                <video width=\"640\" height=\"360\" autoplay loop muted playsinline>\n",
       "                <source src=\"../_static/fig_height_ratio.mp4?randId=767\" type=\"video/mp4\">\n",
       "                </video>\n",
       "            "
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "import diplotocus as dpl\n",
    "import matplotlib.pyplot as plt\n",
    "\n",
    "x = [-1,1,1,-1,-1]\n",
    "y = [-1,-1,1,1,-1]\n",
    "\n",
    "fig,ax = plt.subplots(2,1,figsize=(7,7))\n",
    "ax[0].plot(x,y)\n",
    "ax[1].plot(x,y)\n",
    "tl = dpl.Timeline(fig=fig)\n",
    "\n",
    "a = dpl.fig_height_ratio(start_heights=(1,0),end_heights=(0,1),duration=60)\n",
    "\n",
    "tl.animate(a)\n",
    "tl.save_video('../_static/fig_height_ratio.mp4')"
   ]
  }
 ],
 "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.13.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
