.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "intro/matplotlib/auto_examples/plot_quiver.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end <sphx_glr_download_intro_matplotlib_auto_examples_plot_quiver.py>` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_intro_matplotlib_auto_examples_plot_quiver.py: Plotting a vector field: quiver ================================ A simple example showing how to plot a vector field (quiver) with matplotlib. .. GENERATED FROM PYTHON SOURCE LINES 8-28 .. image-sg:: /intro/matplotlib/auto_examples/images/sphx_glr_plot_quiver_001.png :alt: plot quiver :srcset: /intro/matplotlib/auto_examples/images/sphx_glr_plot_quiver_001.png :class: sphx-glr-single-img .. code-block:: Python import numpy as np import matplotlib.pyplot as plt n = 8 X, Y = np.mgrid[0:n, 0:n] T = np.arctan2(Y - n / 2.0, X - n / 2.0) R = 10 + np.sqrt((Y - n / 2.0) ** 2 + (X - n / 2.0) ** 2) U, V = R * np.cos(T), R * np.sin(T) plt.axes((0.025, 0.025, 0.95, 0.95)) plt.quiver(X, Y, U, V, R, alpha=0.5) plt.quiver(X, Y, U, V, edgecolor="k", facecolor="None", linewidth=0.5) plt.xlim(-1, n) plt.xticks([]) plt.ylim(-1, n) plt.yticks([]) plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.032 seconds) .. _sphx_glr_download_intro_matplotlib_auto_examples_plot_quiver.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_quiver.ipynb <plot_quiver.ipynb>` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_quiver.py <plot_quiver.py>` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_quiver.zip <plot_quiver.zip>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_