.. _sphx_glr_gallery_streamplot.py: Streamplot ---------- Generating a vector-based streamplot. .. image:: /gallery/images/sphx_glr_streamplot_001.png :align: center .. code-block:: python import matplotlib.pyplot as plt import cartopy.crs as ccrs from cartopy.examples.arrows import sample_data def main(): fig = plt.figure(figsize=(10, 5)) ax = fig.add_subplot(1, 1, 1, projection=ccrs.PlateCarree()) ax.set_extent([-90, 75, 10, 85], crs=ccrs.PlateCarree()) ax.coastlines() x, y, u, v, vector_crs = sample_data(shape=(80, 100)) magnitude = (u ** 2 + v ** 2) ** 0.5 ax.streamplot(x, y, u, v, transform=vector_crs, linewidth=2, density=2, color=magnitude) plt.show() if __name__ == '__main__': main() **Total running time of the script:** ( 0 minutes 3.772 seconds) .. container:: sphx-glr-footer .. container:: sphx-glr-download :download:`Download Python source code: streamplot.py ` .. container:: sphx-glr-download :download:`Download Jupyter notebook: streamplot.ipynb ` .. rst-class:: sphx-glr-signature `Generated by Sphinx-Gallery `_