{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# Shade regions defined by a logical mask using fill_between\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import matplotlib.pyplot as plt\nimport numpy as np\n\nt = np.arange(0.0, 2, 0.01)\ns = np.sin(2*np.pi*t)\n\nfig, ax = plt.subplots()\n\nax.plot(t, s, color='black')\nax.axhline(0, color='black')\n\nax.fill_between(t, 1, where=s > 0, facecolor='green', alpha=.5)\nax.fill_between(t, -1, where=s < 0, facecolor='red', alpha=.5)\n\nplt.show()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        ".. admonition:: References\n\n   The use of the following functions, methods, classes and modules is shown\n   in this example:\n\n   - `matplotlib.axes.Axes.fill_between`\n\n.. tags::\n\n   styling: conditional\n   plot-type: fill_between\n   level: beginner\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.14.6"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}