How to make a quiver in polar coordinates

How to make a quiver in polar coordinates? I have data in terms of r and theta. I tried:

import numpy as np radii = np.linspace(0.5,1,10) thetas = np.linspace(0,2*np.pi,20) theta, r = np.meshgrid(thetas, radii) f = plt.figure() ax = f.add_subplot(111, polar=True) ax.quiver(theta, r, dr, dt) 

where dr and dt are data vectors in the r and theta directions.

+6
source share
1 answer

It seems that the quiver is not doing the conversion for you. You need to do the conversion (x, y) → (r, t) manually:

 radii = np.linspace(0.5,1,10) thetas = np.linspace(0,2*np.pi,20) theta, r = np.meshgrid(thetas, radii) dr = 1 dt = 1 f = plt.figure() ax = f.add_subplot(111, polar=True) ax.quiver(theta, r, dr * cos(theta) - dt * sin (theta), dr * sin(theta) + dt * cos(theta)) 

graph

+5
source

All Articles