.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/vector_data/barbs.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_vector_data_barbs.py: Barbs ----- Plotting barbs. .. GENERATED FROM PYTHON SOURCE LINES 8-52 .. image-sg:: /gallery/vector_data/images/sphx_glr_barbs_001.png :alt: barbs :srcset: /gallery/vector_data/images/sphx_glr_barbs_001.png :class: sphx-glr-single-img .. code-block:: Python import matplotlib.pyplot as plt import cartopy.crs as ccrs def sample_data(shape=(20, 30)): """ Return ``(x, y, u, v, crs)`` of some vector data computed mathematically. The returned crs will be a rotated pole CRS, meaning that the vectors will be unevenly spaced in regular PlateCarree space. """ import numpy as np crs = ccrs.RotatedPole(pole_longitude=177.5, pole_latitude=37.5) x = np.linspace(311.9, 391.1, shape[1]) y = np.linspace(-23.6, 24.8, shape[0]) x2d, y2d = np.meshgrid(x, y) u = 10 * (2 * np.cos(2 * np.deg2rad(x2d) + 3 * np.deg2rad(y2d + 30)) ** 2) v = 20 * np.cos(6 * np.deg2rad(x2d)) return x, y, u, v, crs def main(): fig = plt.figure(figsize=(10, 5)) ax = fig.add_subplot(1, 1, 1, projection=ccrs.PlateCarree()) ax.set_extent([-90, 80, 10, 85], crs=ccrs.PlateCarree()) ax.stock_img() ax.coastlines() x, y, u, v, vector_crs = sample_data(shape=(10, 14)) ax.barbs(x, y, u, v, length=5, sizes=dict(emptybarb=0.25, spacing=0.2, height=0.5), linewidth=0.95, transform=vector_crs) plt.show() if __name__ == '__main__': main() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.192 seconds) .. _sphx_glr_download_gallery_vector_data_barbs.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: barbs.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: barbs.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_