
.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "plot_types/arrays/streamplot.py"
.. LINE NUMBERS ARE GIVEN BELOW.

.. only:: html

    .. meta::
        :keywords: codex

    .. note::
        :class: sphx-glr-download-link-note

        :ref:`Go to the end <sphx_glr_download_plot_types_arrays_streamplot.py>`
        to download the full example code.

.. rst-class:: sphx-glr-example-title

.. _sphx_glr_plot_types_arrays_streamplot.py:


======================
streamplot(X, Y, U, V)
======================
Draw streamlines of a vector flow.

See `~matplotlib.axes.Axes.streamplot`.

.. GENERATED FROM PYTHON SOURCE LINES 9-27



.. image-sg:: /plot_types/arrays/images/sphx_glr_streamplot_001.png
   :alt: streamplot
   :srcset: /plot_types/arrays/images/sphx_glr_streamplot_001.png, /plot_types/arrays/images/sphx_glr_streamplot_001_2_00x.png 2.00x
   :class: sphx-glr-single-img





.. code-block:: Python

    import matplotlib.pyplot as plt
    import numpy as np

    plt.style.use('_mpl-gallery-nogrid')

    # make a stream function:
    X, Y = np.meshgrid(np.linspace(-3, 3, 256), np.linspace(-3, 3, 256))
    Z = (1 - X/2 + X**5 + Y**3) * np.exp(-X**2 - Y**2)
    # make U and V out of the streamfunction:
    V = np.diff(Z[1:, :], axis=1)
    U = -np.diff(Z[:, 1:], axis=0)

    # plot:
    fig, ax = plt.subplots()

    ax.streamplot(X[1:, 1:], Y[1:, 1:], U, V)

    plt.show()


.. _sphx_glr_download_plot_types_arrays_streamplot.py:

.. only:: html

  .. container:: sphx-glr-footer sphx-glr-footer-example

    .. container:: sphx-glr-download sphx-glr-download-jupyter

      :download:`Download Jupyter notebook: streamplot.ipynb <streamplot.ipynb>`

    .. container:: sphx-glr-download sphx-glr-download-python

      :download:`Download Python source code: streamplot.py <streamplot.py>`

    .. container:: sphx-glr-download sphx-glr-download-zip

      :download:`Download zipped: streamplot.zip <streamplot.zip>`


.. only:: html

 .. rst-class:: sphx-glr-signature

    `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_
