.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "11_demos\python_packages\matplotlib\demo_streamplot_features.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_11_demos_python_packages_matplotlib_demo_streamplot_features.py: Streamplot ============= Demo of the ``streamplot`` function. A streamplot, or streamline plot, is used to display 2D vector fields. This example shows a few features of the stream plot function: * Varying the color along a streamline. * Varying the density of streamlines. * Varying the line width along a stream line. .. GENERATED FROM PYTHON SOURCE LINES 13-31 .. rst-class:: sphx-glr-horizontal * .. image-sg:: /11_demos/python_packages/matplotlib/images/sphx_glr_demo_streamplot_features_001.png :alt: demo streamplot features :srcset: /11_demos/python_packages/matplotlib/images/sphx_glr_demo_streamplot_features_001.png :class: sphx-glr-multi-img * .. image-sg:: /11_demos/python_packages/matplotlib/images/sphx_glr_demo_streamplot_features_002.png :alt: demo streamplot features :srcset: /11_demos/python_packages/matplotlib/images/sphx_glr_demo_streamplot_features_002.png :class: sphx-glr-multi-img .. code-block:: default import numpy as np import matplotlib.pyplot as plt Y, X = np.mgrid[-3:3:100j, -3:3:100j] U = -1 - X ** 2 + Y V = 1 + X - Y ** 2 speed = np.sqrt(U * U + V * V) plt.streamplot(X, Y, U, V, color=U, linewidth=2, cmap=plt.cm.autumn) plt.colorbar() f, (ax1, ax2) = plt.subplots(ncols=2) ax1.streamplot(X, Y, U, V, density=[0.5, 1]) lw = 5 * speed / speed.max() ax2.streamplot(X, Y, U, V, density=0.6, color="k", linewidth=lw) plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 1.686 seconds) .. _sphx_glr_download_11_demos_python_packages_matplotlib_demo_streamplot_features.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: demo_streamplot_features.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: demo_streamplot_features.ipynb `