Hi folks,
I frequently need to make a vector plot that shows (dx,dy) displacements
from a set of (x,y) points. "Quiver" doesn't seem to do quite what I
want, although maybe I just can't figure out how to use it.
Anyhow here is a function I wrote to do what I want using the pylab
interface, in case it can be cleaned up and incorporated into matplotlib
for general use.
def vectorplot(x,y,dx,dy,scale=1):
""" Generate a vector plot with lines emanating from the (x,y)
points that represent the (dx,dy) displacement at each point.
@param scale: Multiply (dx,dy) by this factor to make the displacements
more visible
@return: (cell_handle, displacement_handle) which can be used
to pass to "legend"
"""
u=x+scale*dx
v=y+scale*dy
#loop through to make the plots
for i in range(len(x)):
dhandle=plot([x[i],u[i]],[y[i],v[i]],'ob',
label='shifts [* %4.1f]'%scale)
#then overplot the origin points in a different color
chandle=plot(x,y,'sk',label='zone')
return (chandle,dhandle)
cheers,
Vicki Laidler
