{ "nbformat_minor": 0, "nbformat": 4, "cells": [ { "execution_count": null, "cell_type": "code", "source": [ "%matplotlib inline" ], "outputs": [], "metadata": { "collapsed": false } }, { "source": [ "\nPlotting a vector field: quiver\n================================\n\nA simple example showing how to plot a vector field (quiver) with\nmatplotlib.\n\n" ], "cell_type": "markdown", "metadata": {} }, { "execution_count": null, "cell_type": "code", "source": [ "import numpy as np\nimport matplotlib.pyplot as plt\n\nn = 8\nX, Y = np.mgrid[0:n, 0:n]\nT = np.arctan2(Y - n / 2., X - n/2.)\nR = 10 + np.sqrt((Y - n / 2.0) ** 2 + (X - n / 2.0) ** 2)\nU, V = R * np.cos(T), R * np.sin(T)\n\nplt.axes([0.025, 0.025, 0.95, 0.95])\nplt.quiver(X, Y, U, V, R, alpha=.5)\nplt.quiver(X, Y, U, V, edgecolor='k', facecolor='None', linewidth=.5)\n\nplt.xlim(-1, n)\nplt.xticks(())\nplt.ylim(-1, n)\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" } } } }