.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/introductory/08.quiver.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_gallery_introductory_08.quiver.py: ====== Quiver ====== 2D field of arrows can be plotted using ``ax.quiver``. .. GENERATED FROM PYTHON SOURCE LINES 8-37 .. image-sg:: /gallery/introductory/images/sphx_glr_08.quiver_001.svg :alt: 08.quiver :srcset: /gallery/introductory/images/sphx_glr_08.quiver_001.svg :class: sphx-glr-single-img .. code-block:: Python import numpy as np import matplotlib.pyplot as plt from mpltern.datasets import get_triangular_grid t, l, r = get_triangular_grid() # Arrows. The sum of the three must be zero. dt = 1.0 / 3.0 - t dl = 1.0 / 3.0 - l dr = 1.0 / 3.0 - r length = np.sqrt(dt ** 2 + dl ** 2 + dr ** 2) fig = plt.figure(figsize=(10.8, 4.8)) fig.subplots_adjust(left=0.075, right=0.85, wspace=0.3) ax = fig.add_subplot(121, projection='ternary') pc = ax.quiver(t, l, r, dt, dl, dr) ax = fig.add_subplot(122, projection='ternary') pc = ax.quiver(t, l, r, dt, dl, dr, length) cax = ax.inset_axes([1.05, 0.1, 0.05, 0.9], transform=ax.transAxes) colorbar = fig.colorbar(pc, cax=cax) colorbar.set_label('Length', rotation=270, va='baseline') plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 1.860 seconds) .. _sphx_glr_download_gallery_introductory_08.quiver.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: 08.quiver.ipynb <08.quiver.ipynb>` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: 08.quiver.py <08.quiver.py>` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_