{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# barbs(X, Y, U, V)\nPlot a 2D field of wind barbs.\n\nSee `~matplotlib.axes.Axes.barbs`.\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-nogrid')\n\n# make data:\nX, Y = np.meshgrid([1, 2, 3, 4], [1, 2, 3, 4])\nangle = np.pi / 180 * np.array([[15., 30, 35, 45],\n [25., 40, 55, 60],\n [35., 50, 65, 75],\n [45., 60, 75, 90]])\namplitude = np.array([[5, 10, 25, 50],\n [10, 15, 30, 60],\n [15, 26, 50, 70],\n [20, 45, 80, 100]])\nU = amplitude * np.sin(angle)\nV = amplitude * np.cos(angle)\n\n# plot:\nfig, ax = plt.subplots()\n\nax.barbs(X, Y, U, V, barbcolor='C0', flagcolor='C0', length=7, linewidth=1.5)\n\nax.set(xlim=(0, 4.5), ylim=(0, 4.5))\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.2" } }, "nbformat": 4, "nbformat_minor": 0 }