Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make a quiver plot in polar coordinates

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.

like image 508
Michaelowski Avatar asked Dec 11 '12 21:12

Michaelowski


People also ask

How do you plot a quiver plot?

Quiver Plot with two arrows Let's add another arrow to the plot passing through two starting points and two directions. By keeping the original arrow starting at origin(0, 0) and pointing towards up and to the right direction(1, 1), and create the second arrow starting at (0, 0) pointing down in direction(0, -1).

How do you plot a polar plot?

Rules for Drawing Polar PlotsWrite the expressions for magnitude and the phase of G(jω)H(jω). Find the starting magnitude and the phase of G(jω)H(jω) by substituting ω=0. So, the polar plot starts with this magnitude and the phase angle. Find the ending magnitude and the phase of G(jω)H(jω) by substituting ω=∞.

What is a quiver plot?

A quiver plot is a type of 2D plot that shows vector lines as arrows. Quiver plots are useful in electrical engineering to visualize electrical potential and valuable in mechanical engineering to show stress gradients.

What is Quiver Matlab?

quiver( U , V ) plots arrows with directional components specified by U and V at equally spaced points. If U and V are vectors, then the x-coordinates of the arrows range from 1 to the number of elements in U and V , and the y-coordinates are all 1.


1 Answers

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

like image 57
tacaswell Avatar answered Sep 28 '22 01:09

tacaswell