{ "nbformat_minor": 0, "nbformat": 4, "cells": [ { "execution_count": null, "cell_type": "code", "source": [ "%matplotlib inline" ], "outputs": [], "metadata": { "collapsed": false } }, { "source": [ "\nPlot and filled plots\n=====================\n\nSimple example of plots and filling between them with matplotlib.\n\n" ], "cell_type": "markdown", "metadata": {} }, { "execution_count": null, "cell_type": "code", "source": [ "import numpy as np\nimport matplotlib.pyplot as plt\n\nn = 256\nX = np.linspace(-np.pi, np.pi, n, endpoint=True)\nY = np.sin(2 * X)\n\nplt.axes([0.025, 0.025, 0.95, 0.95])\n\nplt.plot(X, Y + 1, color='blue', alpha=1.00)\nplt.fill_between(X, 1, Y + 1, color='blue', alpha=.25)\n\nplt.plot(X, Y - 1, color='blue', alpha=1.00)\nplt.fill_between(X, -1, Y - 1, (Y - 1) > -1, color='blue', alpha=.25)\nplt.fill_between(X, -1, Y - 1, (Y - 1) < -1, color='red', alpha=.25)\n\nplt.xlim(-np.pi, np.pi)\nplt.xticks(())\nplt.ylim(-2.5, 2.5)\nplt.yticks(())\n\nplt.show()" ], "outputs": [], "metadata": { "collapsed": false } } ], "metadata": { "kernelspec": { "display_name": "Python 2", "name": "python2", "language": "python" }, "language_info": { "mimetype": "text/x-python", "nbconvert_exporter": "python", "name": "python", "file_extension": ".py", "version": "2.7.12", "pygments_lexer": "ipython2", "codemirror_mode": { "version": 2, "name": "ipython" } } } }