{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# fill_between(x, y1, y2)\nFill the area between two horizontal curves.\n\nSee `~matplotlib.axes.Axes.fill_between`.\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import matplotlib.pyplot as plt\nimport numpy as np\n\nplt.style.use('_mpl-gallery')\n\n# make data\nnp.random.seed(1)\nx = np.linspace(0, 8, 16)\ny1 = 3 + 4*x/8 + np.random.uniform(0.0, 0.5, len(x))\ny2 = 1 + 2*x/8 + np.random.uniform(0.0, 0.5, len(x))\n\n# plot\nfig, ax = plt.subplots()\n\nax.fill_between(x, y1, y2, alpha=.5, linewidth=0)\nax.plot(x, (y1 + y2)/2, linewidth=2)\n\nax.set(xlim=(0, 8), xticks=np.arange(1, 8),\n ylim=(0, 8), yticks=np.arange(1, 8))\n\nplt.show()" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.13.5" } }, "nbformat": 4, "nbformat_minor": 0 }