Vector field - Stream plot¶

In [10]:
import numpy as np
import matplotlib.pyplot as plt

x_range = np.linspace(-3, 3, 11)
y_range = np.linspace(-3, 3, 11)
(x, y) = np.meshgrid(x_range, y_range)
u = np.sin(y)
v = np.cos(x)
mag = np.sqrt(u**2+v**2)

plt.style.use('dark_background')
fig, ax = plt.subplots()
q = plt.streamplot(x, y, u, v, color=mag, cmap='plasma')
cb = plt.colorbar(q.lines)
cb.set_label('Magnitude')
plt.show()
No description has been provided for this image