{ "nbformat_minor": 0, "nbformat": 4, "cells": [ { "execution_count": null, "cell_type": "code", "source": [ "%matplotlib inline" ], "outputs": [], "metadata": { "collapsed": false } }, { "source": [ "\nBar plots\n==========\n\nAn example of bar plots 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 = 12\nX = np.arange(n)\nY1 = (1 - X / float(n)) * np.random.uniform(0.5, 1.0, n)\nY2 = (1 - X / float(n)) * np.random.uniform(0.5, 1.0, n)\n\nplt.axes([0.025, 0.025, 0.95, 0.95])\nplt.bar(X, +Y1, facecolor='#9999ff', edgecolor='white')\nplt.bar(X, -Y2, facecolor='#ff9999', edgecolor='white')\n\nfor x, y in zip(X, Y1):\n plt.text(x + 0.4, y + 0.05, '%.2f' % y, ha='center', va= 'bottom')\n\nfor x, y in zip(X, Y2):\n plt.text(x + 0.4, -y - 0.05, '%.2f' % y, ha='center', va= 'top')\n\nplt.xlim(-.5, n)\nplt.xticks(())\nplt.ylim(-1.25, 1.25)\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" } } } }