{
 "nbformat": 4,
 "nbformat_minor": 5,
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "name": "python",
   "version": "3"
  }
 },
 "cells": [
  {
   "cell_type": "code",
   "id": "cell-0",
   "metadata": {},
   "execution_count": null,
   "outputs": [],
   "source": "# --- house style (the Press palette: accent/navy/gold/parchment) ---\nimport matplotlib as mpl\nACCENT, NAVY, GOLD, PARCH = '#7a1f1f', '#1f3a5f', '#b8860b', '#f7f2e7'\nmpl.rcParams.update({'figure.facecolor': PARCH, 'axes.facecolor': '#fffdf6',\n                     'axes.edgecolor': '#c9bfa3', 'font.family': 'serif'})\n\nimport numpy as np\nimport matplotlib.pyplot as plt\nfrom matplotlib import animation\n\nrho = lambda x: 1.0 + 9.0*np.exp(-x/0.05)      # the boundary-layer rule\nx = np.linspace(0, 1, 4001)\nmass = np.cumsum(rho(x)); mass /= mass[-1]     # the running tesseraction F(x)\n\na = 0.15\nfig, ax = plt.subplots(figsize=(8, 3.5))\ndef draw(t):\n    ax.clear()\n    b = 0.15 + 0.75 * t\n    ax.plot(x, rho(x), color=NAVY, lw=2)\n    m = (x >= a) & (x <= b)\n    ax.fill_between(x[m], rho(x)[m], color=ACCENT, alpha=0.5)\n    v = np.interp(b, x, mass) - np.interp(a, x, mass)\n    ax.set(ylim=(0, 11), title=f\"share of $[a,b]$ = {v:.4f}   (the running tesseraction)\")\n\nani = animation.FuncAnimation(fig, draw, frames=np.linspace(0, 1, 60), interval=60)\n# Colab:  from IPython.display import HTML; HTML(ani.to_jshtml())\n# Web:    ani.save('py03_mirror.gif', writer='pillow', fps=15)\nplt.show()\n"
  }
 ]
}