11

How do I make a quiver plot in polar coordinates? I have data in terms of r and theta. I've 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 vectors of data in the r and theta directions.

tacaswell
  • 84,579
  • 22
  • 210
  • 199
Michaelowski
  • 113
  • 1
  • 5

1 Answers1

10

It looks like quiver does not do the conversion for you. You need to do the (r,t) -> (x,y) conversion by hand:

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

tacaswell
  • 84,579
  • 22
  • 210
  • 199