# Python | Streamline Plot

Here, we are going to learn about the streamline plot and its Python implementation.
Submitted by Anuj Singh, on August 16, 2020

A streamline plot or stream plot (in shorthand) is a type of plotting technique that is specially used to display 2D vector fields. Most of the applications are included in Physics or weather telecasts. When a wind flow is shown on a map is a kind of streamline plotting. Magnetic field lines and electric field lines are shown in our textbooks are the best example of a streamline plot. Following are the key ways by using which we can plot streamline plotting:

pyplot.streamplot() is an inbuilt function in matplotlib.pyplot which performs our required operation.

Illustrations:

## Python code for streamline plot

```import numpy as np
import matplotlib.pyplot as plt

#building a sample meshgrid
w = 6
Y, X = np.mgrid[-w:w:100j, -w:w:100j]
U = -1 - X**2 + Y
V = 1 + X - Y**2
speed = np.sqrt(U**2 + V**2)

plt.figure()

#  Example 1
plt.figure()
plt.streamplot(X, Y, U, V)
plt.title('Basic Streamline Plot')

#  Example 2
plt.figure()
plt.streamplot(X, Y, U, V, linewidth=2.0)
plt.title('Basic Streamline Plot : Linewidth = 2.0')

#  Example 3
plt.figure()
plt.streamplot(X, Y, U, V, color='g', linewidth=0.5)
plt.title('Basic Streamline Plot : Colour Green')
```

Output:

```Output is as Figure
```

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates