
.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "gallery/mplot3d/fillunder3d.py"
.. LINE NUMBERS ARE GIVEN BELOW.

.. only:: html

    .. meta::
        :keywords: codex

    .. note::
        :class: sphx-glr-download-link-note

        :ref:`Go to the end <sphx_glr_download_gallery_mplot3d_fillunder3d.py>`
        to download the full example code.

.. rst-class:: sphx-glr-example-title

.. _sphx_glr_gallery_mplot3d_fillunder3d.py:


=========================
Fill under 3D line graphs
=========================

Demonstrate how to create polygons which fill the space under a line
graph. In this example polygons are semi-transparent, creating a sort
of 'jagged stained glass' effect.

.. GENERATED FROM PYTHON SOURCE LINES 10-36

.. code-block:: Python


    import math

    import matplotlib.pyplot as plt
    import numpy as np

    gamma = np.vectorize(math.gamma)
    N = 31
    x = np.linspace(0., 10., N)
    lambdas = range(1, 9)

    ax = plt.figure().add_subplot(projection='3d')

    facecolors = plt.colormaps['viridis_r'](np.linspace(0, 1, len(lambdas)))

    for i, l in enumerate(lambdas):
        # Note fill_between can take coordinates as length N vectors, or scalars
        ax.fill_between(x, l, l**x * np.exp(-l) / gamma(x + 1),
                        x, l, 0,
                        facecolors=facecolors[i], alpha=.7)

    ax.set(xlim=(0, 10), ylim=(1, 9), zlim=(0, 0.35),
           xlabel='x', ylabel=r'$\lambda$', zlabel='probability')

    plt.show()


.. GENERATED FROM PYTHON SOURCE LINES 37-41

.. tags::
   plot-type: 3D,
   plot-type: fill_between,
   level: beginner


.. _sphx_glr_download_gallery_mplot3d_fillunder3d.py:

.. only:: html

  .. container:: sphx-glr-footer sphx-glr-footer-example

    .. container:: sphx-glr-download sphx-glr-download-jupyter

      :download:`Download Jupyter notebook: fillunder3d.ipynb <fillunder3d.ipynb>`

    .. container:: sphx-glr-download sphx-glr-download-python

      :download:`Download Python source code: fillunder3d.py <fillunder3d.py>`

    .. container:: sphx-glr-download sphx-glr-download-zip

      :download:`Download zipped: fillunder3d.zip <fillunder3d.zip>`


.. only:: html

 .. rst-class:: sphx-glr-signature

    `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_
