quiver with angles

Im a bit confused of how I should use the "quiver" plotting function.

My data is 2D, a 512x512 data array, where every entry is an angle
(polarimetry).
I also have an array with the degree of polarization which would be nice to
colour-code in to the arrows.
So:
How do I use my angles to control the direction of the arrows, and how do I
get values to control the colour of the arrows?

Cheers,
Magnus

···

--
View this message in context: http://www.nabble.com/quiver-with-angles-tp25397027p25397027.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

n.l.o wrote:

Im a bit confused of how I should use the "quiver" plotting function.

My data is 2D, a 512x512 data array, where every entry is an angle
(polarimetry).
I also have an array with the degree of polarization which would be nice to
colour-code in to the arrows.
So:
How do I use my angles to control the direction of the arrows, and how do I
get values to control the colour of the arrows?

Cheers,
Magnus

Example with ipython -pylab:

x = arange(4)
y = arange(5)
X, Y = meshgrid(x, y)
u = ones_like(X)
v = zeros_like(X)
c = arange(u.size) # values mapped to colors
angles = (X * 20 + Y * 20).ravel()
quiver(X, Y, u, v, c, angles=angles)
axis([-1, 4, -1, 5])

The .ravel() of the angles is to get around a bug that I fixed a few minutes ago in svn.

Eric

I tried the code you supplied and I didn't get it to work with the *angles*
keyword, I got:
"ValueError: shape mismatch: objects cannot be broadcast to a single shape"
I have matplotlib.__version__ = '0.98.5.2'.

Although after thinking about it for a while I did:

from scipy import *
import matplotlib.pyplot as plt

X,Y = meshgrid(arange(64),arange(64)) # a bit bigger just to see what it
looks like
angles = arange(0,4*pi,4.*pi/X.size) # just creating a set of angles

u = cos(angles)
v = sin(angles)

c = arange(u.size) # the colours!
c.shape = X.shape
plt.quiver(X, Y, u, v, c, pivot='middle',minlength=0.04, width=0.05,
headwidth=1,scale=50)

that is, the angles are converted to "u" and "v" parameters.

Anyway. That is how I got it working.

efiring wrote:

···

Example with ipython -pylab:

x = arange(4)
y = arange(5)
X, Y = meshgrid(x, y)
u = ones_like(X)
v = zeros_like(X)
c = arange(u.size) # values mapped to colors
angles = (X * 20 + Y * 20).ravel()
quiver(X, Y, u, v, c, angles=angles)
axis([-1, 4, -1, 5])

The .ravel() of the angles is to get around a bug that I fixed a few
minutes ago in svn.

Eric

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008
30-Day
trial. Simplify your report design, integration and deployment - and focus
on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

--
View this message in context: http://www.nabble.com/quiver-with-angles-tp25397027p25422103.html
Sent from the matplotlib - users mailing list archive at Nabble.com.