Zane Selvans wrote:
> Hey there,
> 
> I'm trying to plot a bunch-o-vectors, colored red or blue, depending on 
> whether their magnitude is positive or negative (they represent 
> stresses), and I'm doing something like this:
> 
> mag1 = evals[:,0]
> ex1  = evecs[:,0,1]
> ey1  = evecs[:,0,0]
> C1 = np.where(mag1 >= 0, 'red', 'blue')
> 
> mag2 = evals[:,1]
> ex2  = evecs[:,1,1]
> ey2  = evecs[:,1,0]
> C2 = np.where(mag2 >= 0, 'red', 'blue')
> 

The C argument to quiver is for an array to be used with a colormap; you 
could use that with a listed colormap, or, to use something very close 
to what you already have, try using the "color" kwarg for your C1 and 
C2.  It takes a single value or a sequence of color specs.

Eric

> basemap_ax.quiver(np.degrees(calc_phis), 
> np.degrees(np.pi/2.0-calc_thetas),  mag1*ex1,  mag1*ey1, C1, lw=0, 
> width=0.002, scale=1e8)
> basemap_ax.quiver(np.degrees(calc_phis), 
> np.degrees(np.pi/2.0-calc_thetas),  mag2*ex2,  mag2*ey2, C2, lw=0, 
> width=0.002, scale=1e8)
> basemap_ax.quiver(np.degrees(calc_phis), 
> np.degrees(np.pi/2.0-calc_thetas), -mag1*ex1, -mag1*ey1, C1, lw=0, 
> width=0.002, scale=1e8)
> basemap_ax.quiver(np.degrees(calc_phis), 
> np.degrees(np.pi/2.0-calc_thetas), -mag2*ex2, -mag2*ey2, C2, lw=0, 
> width=0.002, scale=1e8)
> 
> And it gives me the stack trace below...  I also tried just using 
> plain-old quiver (not via basemap) and got the same error.  I tried 
> using rgba tuples and grayscale strings as colors as well, and still got 
> the same error.  Anybody have any idea what the deal is?  Or am I 
> misunderstanding what *C* is supposed to be (i.e. not just an array of 
> colors, of the same length as the number of vectors being plotted...)
> 
> /Library/Python/2.5/site-packages/mpl_toolkits/basemap/__init__.pyc in 
> quiver(self, x, y, u, v, *args, **kwargs)
>    2877             ax.hold(h)
>    2878         try:
> -> 2879             ret =  ax.quiver(x,y,u,v,*args,**kwargs)
>    2880             try:
>    2881                 plt.draw_if_interactive()
> 
> /Library/Python/2.5/site-packages/matplotlib/axes.pyc in quiver(self, 
> *args, **kw)
>    5850     def quiver(self, *args, **kw):
>    5851         if not self._hold: self.cla()
> -> 5852         q = mquiver.Quiver(self, *args, **kw)
>    5853         self.add_collection(q, False)
>    5854         self.update_datalim(q.XY)
> 
> /Library/Python/2.5/site-packages/matplotlib/quiver.pyc in 
> __init__(self, ax, *args, **kw)
>     367                                             **kw)
>     368         self.polykw = kw
> --> 369         self.set_UVC(U, V, C)
>     370         self._initialized = False
>     371
> 
> /Library/Python/2.5/site-packages/matplotlib/quiver.pyc in set_UVC(self, 
> U, V, C)
>     439         mask = ma.mask_or(U.mask, V.mask, copy=False, shrink=True)
>     440         if C is not None:
> --> 441             C = ma.masked_invalid(C, copy=False).ravel()
>     442             mask = ma.mask_or(mask, C.mask, copy=False, shrink=True)
>     443             if mask is ma.nomask:
> 
> /Library/Python/2.5/site-packages/numpy/ma/core.pyc in masked_invalid(a, 
> copy)
>    1996     """
>    1997     a = np.array(a, copy=copy, subok=True)
> -> 1998     condition = ~(np.isfinite(a))
>    1999     if hasattr(a, '_mask'):
>    2000         condition = mask_or(condition, a._mask)
> 
> TypeError: bad operand type for unary ~: 'NotImplementedType'
> 
> 
> -- 
> Zane A. Selvans
> Amateur Earthling
> http://zaneselvans.org
> +1 303 815 6866
> 
> 
> ------------------------------------------------------------------------
> 
> ------------------------------------------------------------------------------
> 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
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users


------------------------------------------------------------------------------
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
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to