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

.. only:: html

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

        Click :ref:`here <sphx_glr_download_gallery_pyplots_whats_new_98_4_fill_between.py>`
        to download the full example code

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

.. _sphx_glr_gallery_pyplots_whats_new_98_4_fill_between.py:


============
Fill Between
============

Fill the area between two curves.

.. GENERATED FROM PYTHON SOURCE LINES 8-23

.. code-block:: default

    import matplotlib.pyplot as plt
    import numpy as np

    x = np.arange(-5, 5, 0.01)
    y1 = -5*x*x + x + 10
    y2 = 5*x*x + x

    fig, ax = plt.subplots()
    ax.plot(x, y1, x, y2, color='black')
    ax.fill_between(x, y1, y2, where=(y2 > y1), facecolor='yellow', alpha=0.5)
    ax.fill_between(x, y1, y2, where=(y2 <= y1), facecolor='red', alpha=0.5)
    ax.set_title('Fill Between')

    plt.show()




.. image:: /gallery/pyplots/images/sphx_glr_whats_new_98_4_fill_between_001.png
    :alt: Fill Between
    :class: sphx-glr-single-img





.. GENERATED FROM PYTHON SOURCE LINES 24-31

------------

References
""""""""""

The use of the following functions, methods, classes and modules is shown
in this example:

.. GENERATED FROM PYTHON SOURCE LINES 32-35

.. code-block:: default


    import matplotlib
    matplotlib.axes.Axes.fill_between




.. rst-class:: sphx-glr-script-out

 Out:

 .. code-block:: none


    <function Axes.fill_between at 0x7f73be8fc5e0>




.. _sphx_glr_download_gallery_pyplots_whats_new_98_4_fill_between.py:


.. only :: html

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



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

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



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

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


.. only:: html

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

    Keywords: matplotlib code example, codex, python plot, pyplot
    `Gallery generated by Sphinx-Gallery
    <https://sphinx-gallery.readthedocs.io>`_
