43 lines
1.3 KiB
Plaintext
43 lines
1.3 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"\n# Plotting a vector field: quiver\n\nA simple example showing how to plot a vector field (quiver) with\nmatplotlib.\n"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {
|
|
"collapsed": false
|
|
},
|
|
"outputs": [],
|
|
"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.0, X - n / 2.0)\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=0.5)\nplt.quiver(X, Y, U, V, edgecolor=\"k\", facecolor=\"None\", linewidth=0.5)\n\nplt.xlim(-1, n)\nplt.xticks([])\nplt.ylim(-1, n)\nplt.yticks([])\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.12.11"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 0
|
|
} |