{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n# streamplot(X, Y, U, V)\nDraw streamlines of a vector flow.\n\nSee `~matplotlib.axes.Axes.streamplot`.\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 a stream function:\nX, Y = np.meshgrid(np.linspace(-3, 3, 256), np.linspace(-3, 3, 256))\nZ = (1 - X/2 + X**5 + Y**3) * np.exp(-X**2 - Y**2)\n# make U and V out of the streamfunction:\nV = np.diff(Z[1:, :], axis=1)\nU = -np.diff(Z[:, 1:], axis=0)\n\n# plot:\nfig, ax = plt.subplots()\n\nax.streamplot(X[1:, 1:], Y[1:, 1:], U, V)\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
}