{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "%matplotlib inline"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\nAnimation of a zoom\n======================\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "Some Setup\n----------------------------------\nThere are multiple ways to animate a zoom with matplotlib. This package use one very close to the one below.\n\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import chaoseverywhere as chaos\nimport matplotlib.pyplot as plt\nimport matplotlib.animation as animation"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "See a self-similar structure\n-----------------------------------\nThe Mandelbrot set is clearly not a self-similar object. But inside it, we can see structures repeating themselves.\n\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "plt.figure()\nplt.axis('off')\nplt.imshow(chaos.Mandelbrot_disp(-1, -.3, 0.4-110/300,\n            t_max=100,\n            precision=400).mandelbrot(), cmap='bone')\nplt.show()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "One way to animate a zoom\n-----------------------------------\n\n.. code-block:: python\n\n  im_init = chaos.Mandelbrot_disp(-.5,0,1.5)\n  im_init = im_init.mandelbrot()\n  fig = plt.figure()\n  im = plt.imshow(im_init, cmap='bone', animated=True)\n\n  ims = []\n  for i in range(150):\n      im = plt.imshow(chaos.Mandelbrot_disp(-1, -.3, 0.4-i/300,\n              t_max=100,\n              precision=400).mandelbrot(), animated=True, cmap='bone')\n      ims.append([im])\n  ani = animation.ArtistAnimation(fig, ims, interval=50)\n  plt.show()\n\n\nThis is one way to display the animation. However, one might want a shorter way.\nAnd forntunatly, this is what this package provides.\n\n.. code-block:: python\n\n  chaos.Mandelbrot_disp(-.5,0,1.5).animate_mandel_plt()\n\n\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "The video\n----------------\nThis package uses FFMPEG as writer to create and save this animation.\nBecause of the symmetry, we zoomed in on the point $-1-0.3i$ and we can play with the\nnumber of frames to end the animation with a zoom out from the point $-1+0.3i$.\n\n.. raw:: html\n\n    <iframe width=\"356\" height=\"200\" src=\"https://www.youtube.com/embed/v=1QskVC57vc8?rel=0&loop=1&playlist=1QskVC57vc8\" frameborder=\"0\" allowfullscreen></iframe>\n\n\n"
      ]
    }
  ],
  "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.3"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}