

.. _sphx_glr_gallery_lines_bars_and_markers_fill.py:


==============
Fill plot demo
==============

First example showcases the most basic fill plot a user can do with matplotlib.

Second example shows a few optional features:

    * Multiple curves with a single command.
    * Setting the fill color.
    * Setting the opacity (alpha value).




.. rst-class:: sphx-glr-horizontal


    *

      .. image:: /gallery/lines_bars_and_markers/images/sphx_glr_fill_001.png
            :scale: 47

    *

      .. image:: /gallery/lines_bars_and_markers/images/sphx_glr_fill_002.png
            :scale: 47





.. code-block:: python

    import numpy as np
    import matplotlib.pyplot as plt

    x = np.linspace(0, 1, 500)
    y = np.sin(4 * np.pi * x) * np.exp(-5 * x)

    fig, ax = plt.subplots()

    ax.fill(x, y, zorder=10)
    ax.grid(True, zorder=5)

    x = np.linspace(0, 2 * np.pi, 500)
    y1 = np.sin(x)
    y2 = np.sin(3 * x)

    fig, ax = plt.subplots()
    ax.fill(x, y1, 'b', x, y2, 'r', alpha=0.3)
    plt.show()

**Total running time of the script:** ( 0 minutes  0.072 seconds)



.. container:: sphx-glr-footer


  .. container:: sphx-glr-download

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



  .. container:: sphx-glr-download

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

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

    `Generated by Sphinx-Gallery <https://sphinx-gallery.readthedocs.io>`_
