

.. _sphx_glr_gallery_lines_bars_and_markers_fill.py:


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

Demo fill plot.



.. 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)







First, the most basic fill plot a user can make with matplotlib:



.. code-block:: python


    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)




.. image:: /gallery/lines_bars_and_markers/images/sphx_glr_fill_001.png
    :align: center




Next, a few more optional features:

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



.. code-block:: python


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



.. image:: /gallery/lines_bars_and_markers/images/sphx_glr_fill_002.png
    :align: center




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



.. only :: html

 .. 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>`


.. only:: html

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

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