{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# Text printing decorated\n\nAn example showing text printing and decorating the resulting figure.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import numpy as np\nimport matplotlib.pyplot as plt\n\nfig = plt.figure()\nplt.xticks([])\nplt.yticks([])\n\neqs = []\neqs.append(\n    r\"$W^{3\\beta}_{\\delta_1 \\rho_1 \\sigma_2} = U^{3\\beta}_{\\delta_1 \\rho_1} + \\frac{1}{8 \\pi 2} \\int^{\\alpha_2}_{\\alpha_2} d \\alpha^\\prime_2 \\left[\\frac{ U^{2\\beta}_{\\delta_1 \\rho_1} - \\alpha^\\prime_2U^{1\\beta}_{\\rho_1 \\sigma_2} }{U^{0\\beta}_{\\rho_1 \\sigma_2}}\\right]$\"\n)\neqs.append(\n    r\"$\\frac{d\\rho}{d t} + \\rho \\vec{v}\\cdot\\nabla\\vec{v} = -\\nabla p + \\mu\\nabla^2 \\vec{v} + \\rho \\vec{g}$\"\n)\neqs.append(r\"$\\int_{-\\infty}^\\infty e^{-x^2}dx=\\sqrt{\\pi}$\")\neqs.append(r\"$E = mc^2 = \\sqrt{{m_0}^2c^4 + p^2c^2}$\")\neqs.append(r\"$F_G = G\\frac{m_1m_2}{r^2}$\")\n\nrng = np.random.default_rng()\n\nfor i in range(24):\n    index = rng.integers(0, len(eqs))\n    eq = eqs[index]\n    size = rng.uniform(12, 32)\n    x, y = rng.uniform(0, 1, 2)\n    alpha = rng.uniform(0.25, 0.75)\n    plt.text(\n        x,\n        y,\n        eq,\n        ha=\"center\",\n        va=\"center\",\n        color=\"#11557c\",\n        alpha=alpha,\n        transform=plt.gca().transAxes,\n        fontsize=size,\n        clip_on=True,\n    )\n\n\n# Add a title and a box around it\nfrom matplotlib.patches import FancyBboxPatch\n\nax = plt.gca()\nax.add_patch(\n    FancyBboxPatch(\n        (-0.05, 0.87),\n        width=0.66,\n        height=0.165,\n        clip_on=False,\n        boxstyle=\"square,pad=0\",\n        zorder=3,\n        facecolor=\"white\",\n        alpha=1.0,\n        transform=plt.gca().transAxes,\n    )\n)\n\nplt.text(\n    -0.05,\n    1.02,\n    \" Text:                   plt.text(...)\\n\",\n    horizontalalignment=\"left\",\n    verticalalignment=\"top\",\n    size=\"xx-large\",\n    transform=plt.gca().transAxes,\n)\n\nplt.text(\n    -0.05,\n    1.01,\n    \"\\n\\n     Draw any kind of text \",\n    horizontalalignment=\"left\",\n    verticalalignment=\"top\",\n    size=\"large\",\n    transform=plt.gca().transAxes,\n)\n\nplt.show()"
      ]
    }
  ],
  "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.12.11"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}