{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# Fill under 3D line graphs\n\nDemonstrate how to create polygons which fill the space under a line\ngraph. In this example polygons are semi-transparent, creating a sort\nof 'jagged stained glass' effect.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import math\n\nimport matplotlib.pyplot as plt\nimport numpy as np\n\ngamma = np.vectorize(math.gamma)\nN = 31\nx = np.linspace(0., 10., N)\nlambdas = range(1, 9)\n\nax = plt.figure().add_subplot(projection='3d')\n\nfacecolors = plt.colormaps['viridis_r'](np.linspace(0, 1, len(lambdas)))\n\nfor i, l in enumerate(lambdas):\n    # Note fill_between can take coordinates as length N vectors, or scalars\n    ax.fill_between(x, l, l**x * np.exp(-l) / gamma(x + 1),\n                    x, l, 0,\n                    facecolors=facecolors[i], alpha=.7)\n\nax.set(xlim=(0, 10), ylim=(1, 9), zlim=(0, 0.35),\n       xlabel='x', ylabel=r'$\\lambda$', zlabel='probability')\n\nplt.show()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        ".. tags::\n   plot-type: 3D,\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.7"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}