Making vector plots with quiver

We want to plot both the X and the Y changes together. For this, we can use the quiver method. To use the quiver method, insert the (phi) [1] and (phi) [0] gradients into the gradient method. When we call this default set of arguments, the x and y positions, as well as the length of the x and y vectors we provide, will create the following vector field:

# Vectors with quiverplt.imshow(phi, extent=(0,10,0,10), interpolation='none', origin='lower')plt.quiver(x, y, np.gradient(phi)[0], np.gradient(phi)[1])

Following is the output of the preceding code:

We can also change the scale. Usually, after passing a scale ...

Get Mastering Matplotlib 2.x now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.