All Courses

Matplotlib - Quiver Plot

Ekansh Chahre

a year ago

A quiver plot displays the velocity vectors as arrows with components (u,v) at the points (x,y).

The above command plots vectors as arrows at the coordinates specified in each corresponding pair of elements in x and y.


The following table lists down the different parameters for the Quiver plot −
The following code draws a simple quiver plot −

import matplotlib.pyplot as plt
import numpy as np
x,y = np.meshgrid(np.arange(-2, 2, .2), np.arange(-2, 2, .25))
z = x*np.exp(-x**2 - y**2)
v, u = np.gradient(z, .2, .2)
fig, ax = plt.subplots()
q = ax.quiver(x,y,u,v)

Submit Review