.. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_intro_matplotlib_auto_examples_plot_plot.py: Plot and filled plots ===================== Simple example of plots and filling between them with matplotlib. .. image:: /intro/matplotlib/auto_examples/images/sphx_glr_plot_plot_001.png :class: sphx-glr-single-img .. code-block:: python import numpy as np import matplotlib.pyplot as plt n = 256 X = np.linspace(-np.pi, np.pi, n) Y = np.sin(2 * X) plt.axes([0.025, 0.025, 0.95, 0.95]) plt.plot(X, Y + 1, color='blue', alpha=1.00) plt.fill_between(X, 1, Y + 1, color='blue', alpha=.25) plt.plot(X, Y - 1, color='blue', alpha=1.00) plt.fill_between(X, -1, Y - 1, (Y - 1) > -1, color='blue', alpha=.25) plt.fill_between(X, -1, Y - 1, (Y - 1) < -1, color='red', alpha=.25) plt.xlim(-np.pi, np.pi) plt.xticks([]) plt.ylim(-2.5, 2.5) plt.yticks([]) plt.show() **Total running time of the script:** ( 0 minutes 0.019 seconds) .. _sphx_glr_download_intro_matplotlib_auto_examples_plot_plot.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download :download:`Download Python source code: plot_plot.py ` .. container:: sphx-glr-download :download:`Download Jupyter notebook: plot_plot.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_