{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# Plotting a sine\n\nAn introductory example: a Matplotlib figure, some narrative between the code\nblocks, and mathematics rendered with MathJax.\n\nA gallery script starts with a triple-quoted docstring written in\nreStructuredText, whose first line is the title of the example. Code and text\nblocks follow it; a line beginning with ``# %%`` starts a new block, and a\ncomment block after it is rendered as prose rather than as code.\n\nMathematics is written as it is anywhere else in the documentation. This\nexample plots\n\n\\begin{align}x \\rightarrow \\sin(x)\\end{align}\n\nwhere $\\sin$ is evaluated at every point of $x$. Escape the\nbackslashes when the mathematics is inside a plain docstring, or make the\ndocstring raw.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import matplotlib.pyplot as plt\nimport numpy as np\n\ntry:\n    import mplstyle_reslumen  # noqa: F401\n\n    plt.style.use(\"reslumen\")\nexcept ImportError:\n    pass\n\nx = np.linspace(0, 2 * np.pi, 100)\ny = np.sin(x)\n\nplt.plot(x, y)\nplt.xlabel(r\"$x$\")\nplt.ylabel(r\"$\\sin(x)$\")\nplt.show()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "Text blocks and code blocks alternate, so the narrative can explain what the\ncode below it is about to do. Output printed by a block is captured and shown\nunder it:\n\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "print(\"This example shows a sine plot.\")"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Cross-referencing\n\nEvery example gets a label of its own, so one example can link to another\nwith an ordinary reference \u2014 see `sphx_glr_gallery_thumbnail.py` for the\nexample that chooses its own thumbnail.\n\n<div class=\"alert alert-info\"><h4>Note</h4>\n\nDirectives work here exactly as they do on a hand-written page.\n\n</div>\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.13.3"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}