quiver units

Hi Everyone,

I’m trying to make a quiver plot using the example in examples collection.
The documentation says that I can define the arrow units as:

units: [‘width’ | ‘height’ | ‘dots’ | ‘inches’ | ‘x’ | ‘y’ | ‘xy’]so I did:
from pylab import *
from numpy import ma

X,Y = meshgrid( arange(0,2pi,.2),arange(0,2pi,.2) )
U = cos(X)

V = sin(Y)

figure()
M = sqrt(pow(U, 2) + pow(V, 2))
Q = quiver( X, Y, U, V, M, units=‘x’, pivot=‘tip’, width=0.022, scale=1/0.15)

Q = quiver( X, Y, U, V, M, units=‘xy’, pivot=‘tip’, width=0.022, scale=1/0.15)

qk = quiverkey(Q, 0.9, 1.05, 1, r’$1 \frac{m}{s}$’,
labelpos=‘E’,
fontproperties={‘weight’: ‘bold’})
plot(X, Y, ‘k.’)

axis([-1, 7, -1, 7])
title(“scales with x view; pivot=‘tip’”)
show()

When I actually try the option ‘xy’ I get the following error:

Exception in Tkinter callback
Traceback (most recent call last):

File “/usr/lib/python2.6/lib-tk/Tkinter.py”, line 1413, in call
return self.func(*args)
File “/usr/lib/pymodules/python2.6/matplotlib/backends/backend_tkagg.py”, line 212, in resize

self.show()

File “/usr/lib/pymodules/python2.6/matplotlib/backends/backend_tkagg.py”, line 215, in draw
FigureCanvasAgg.draw(self)
File “/usr/lib/pymodules/python2.6/matplotlib/backends/backend_agg.py”, line 314, in draw

self.figure.draw(self.renderer)

File “/usr/lib/pymodules/python2.6/matplotlib/artist.py”, line 46, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File “/usr/lib/pymodules/python2.6/matplotlib/figure.py”, line 773, in draw

for a in self.axes: a.draw(renderer)

File “/usr/lib/pymodules/python2.6/matplotlib/artist.py”, line 46, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File “/usr/lib/pymodules/python2.6/matplotlib/axes.py”, line 1735, in draw

a.draw(renderer)

File “/usr/lib/pymodules/python2.6/matplotlib/artist.py”, line 46, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File “/usr/lib/pymodules/python2.6/matplotlib/quiver.py”, line 436, in draw

self._init()

File “/usr/lib/pymodules/python2.6/matplotlib/quiver.py”, line 425, in _init
trans = self._set_transform()
File “/usr/lib/pymodules/python2.6/matplotlib/quiver.py”, line 481, in _set_transform

raise ValueError('unrecognized units')

ValueError: unrecognized units

Can someone point to where am I mistaken ? Is it a mistake in the documentation ?

Thanks,

···

Oz Nahum
Graduate Student
Zentrum für Angewandte Geologie
Universität Tübingen


Imagine there’s no countries
it isn’t hard to do
Nothing to kill or die for
And no religion too

Imagine all the people
Living life in peace

Your code works fine for me here on 1.0.0. What version are you running?

Ryan

···

On Wed, Sep 15, 2010 at 7:27 AM, Oz Nahum <nahumoz@...287...> wrote:

Hi Everyone,

I'm trying to make a quiver plot using the example in examples collection.
The documentation says that I can define the arrow units as:

units: [‘width’ | ‘height’ | ‘dots’ | ‘inches’ | ‘x’ | ‘y’ | ‘xy’]so I did:
from pylab import *
from numpy import ma

X,Y = meshgrid( arange(0,2*pi,.2),arange(0,2*pi,.2) )
U = cos(X)
V = sin(Y)

figure()
M = sqrt(pow(U, 2) + pow(V, 2))
Q = quiver( X, Y, U, V, M, units='x', pivot='tip', width=0.022,
scale=1/0.15)

Q = quiver( X, Y, U, V, M, units='xy', pivot='tip', width=0.022,
scale=1/0.15)

qk = quiverkey(Q, 0.9, 1.05, 1, r'1 \\frac\{m\}\{s\}',
labelpos='E',
fontproperties={'weight': 'bold'})
plot(X, Y, 'k.')
axis([-1, 7, -1, 7])
title("scales with x view; pivot='tip'")
show()

When I actually try the option 'xy' I get the following error:

Exception in Tkinter callback
Traceback (most recent call last):
File "/usr/lib/python2.6/lib-tk/Tkinter.py", line 1413, in __call__
return self.func(*args)
File "/usr/lib/pymodules/python2.6/matplotlib/backends/backend_tkagg.py",
line 212, in resize
self.show()
File "/usr/lib/pymodules/python2.6/matplotlib/backends/backend_tkagg.py",
line 215, in draw
FigureCanvasAgg.draw(self)
File "/usr/lib/pymodules/python2.6/matplotlib/backends/backend_agg.py",
line 314, in draw
self.figure.draw(self.renderer)
File "/usr/lib/pymodules/python2.6/matplotlib/artist.py", line 46, in
draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "/usr/lib/pymodules/python2.6/matplotlib/figure.py", line 773, in
draw
for a in self.axes: a.draw(renderer)
File "/usr/lib/pymodules/python2.6/matplotlib/artist.py", line 46, in
draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "/usr/lib/pymodules/python2.6/matplotlib/axes.py", line 1735, in draw
a.draw(renderer)
File "/usr/lib/pymodules/python2.6/matplotlib/artist.py", line 46, in
draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "/usr/lib/pymodules/python2.6/matplotlib/quiver.py", line 436, in
draw
self._init()
File "/usr/lib/pymodules/python2.6/matplotlib/quiver.py", line 425, in
_init
trans = self._set_transform()
File "/usr/lib/pymodules/python2.6/matplotlib/quiver.py", line 481, in
_set_transform
raise ValueError('unrecognized units')
ValueError: unrecognized units

Can someone point to where am I mistaken ? Is it a mistake in the
documentation ?

--
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma

Hi Ryan
Thanks for your reply.
I am using 0.99.3 from Debian …

···

On Wed, Sep 15, 2010 at 3:18 PM, Ryan May <rmay31@…287…> wrote:

On Wed, Sep 15, 2010 at 7:27 AM, Oz Nahum <nahumoz@…287…> wrote:

Hi Everyone,

I’m trying to make a quiver plot using the example in examples collection.

The documentation says that I can define the arrow units as:

units: [‘width’ | ‘height’ | ‘dots’ | ‘inches’ | ‘x’ | ‘y’ | ‘xy’]so I did:

from pylab import *

from numpy import ma

X,Y = meshgrid( arange(0,2pi,.2),arange(0,2pi,.2) )

U = cos(X)

V = sin(Y)

figure()

M = sqrt(pow(U, 2) + pow(V, 2))

Q = quiver( X, Y, U, V, M, units=‘x’, pivot=‘tip’, width=0.022,

scale=1/0.15)

Q = quiver( X, Y, U, V, M, units=‘xy’, pivot=‘tip’, width=0.022,

scale=1/0.15)

qk = quiverkey(Q, 0.9, 1.05, 1, r’1 \frac{m}{s}',

                        labelpos='E',
                        fontproperties={'weight': 'bold'})

plot(X, Y, ‘k.’)

axis([-1, 7, -1, 7])

title(“scales with x view; pivot=‘tip’”)

show()

When I actually try the option ‘xy’ I get the following error:

Exception in Tkinter callback

Traceback (most recent call last):

File “/usr/lib/python2.6/lib-tk/Tkinter.py”, line 1413, in call

return self.func(*args)

File “/usr/lib/pymodules/python2.6/matplotlib/backends/backend_tkagg.py”,

line 212, in resize

self.show()

File “/usr/lib/pymodules/python2.6/matplotlib/backends/backend_tkagg.py”,

line 215, in draw

FigureCanvasAgg.draw(self)

File “/usr/lib/pymodules/python2.6/matplotlib/backends/backend_agg.py”,

line 314, in draw

self.figure.draw(self.renderer)

File “/usr/lib/pymodules/python2.6/matplotlib/artist.py”, line 46, in

draw_wrapper

draw(artist, renderer, *args, **kwargs)

File “/usr/lib/pymodules/python2.6/matplotlib/figure.py”, line 773, in

draw

for a in self.axes: a.draw(renderer)

File “/usr/lib/pymodules/python2.6/matplotlib/artist.py”, line 46, in

draw_wrapper

draw(artist, renderer, *args, **kwargs)

File “/usr/lib/pymodules/python2.6/matplotlib/axes.py”, line 1735, in draw

a.draw(renderer)

File “/usr/lib/pymodules/python2.6/matplotlib/artist.py”, line 46, in

draw_wrapper

draw(artist, renderer, *args, **kwargs)

File “/usr/lib/pymodules/python2.6/matplotlib/quiver.py”, line 436, in

draw

self._init()

File “/usr/lib/pymodules/python2.6/matplotlib/quiver.py”, line 425, in

_init

trans = self._set_transform()

File “/usr/lib/pymodules/python2.6/matplotlib/quiver.py”, line 481, in

_set_transform

raise ValueError('unrecognized units')

ValueError: unrecognized units

Can someone point to where am I mistaken ? Is it a mistake in the

documentation ?

Your code works fine for me here on 1.0.0. What version are you running?

Ryan

Ryan May

Graduate Research Assistant

School of Meteorology

University of Oklahoma


Oz Nahum
Graduate Student
Zentrum für Angewandte Geologie
Universität Tübingen


Imagine there’s no countries
it isn’t hard to do

Nothing to kill or die for
And no religion too
Imagine all the people
Living life in peace