1. quiver
The quiver
method is used to plot vector fields in matplotlib
.
A vector field is a mathematical model of the magnitude and direction of different vectors in a 2D or 3D space.
These are used to represent different physical quantities like:
Electromagnetic fields
Fluid dynamics, and more
How To Use?
quiver([X, Y], U, V, [C], **kwargs)
The parameters passed to this method are as follows:
X, Y
: define the x and y coordinates of the arrow locationsU, V
: define the x and y direction components of the arrow vectors/directionsC
: sets the colour of the arrows
Example Plot
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(0, 2*np.pi, 20)
y = np.linspace(0, 2*np.pi, 20)
# Starting positions of the vectors in the vector field
X, Y = np.meshgrid(x, y)
# Horizontal component of the vectors
U = np.cos(X)
# Vertical component of the vectors
V = np.sin(Y)
plt.quiver…
Keep reading with a 7-day free trial
Subscribe to Into AI to keep reading this post and get 7 days of free access to the full post archives.