@@ -4051,34 +4051,6 @@ def scatter(self, x, y, s=20, c='b', marker='o', cmap=None, norm=None,
40514051
40524052 scatter .__doc__ = cbook .dedent (scatter .__doc__ ) % martist .kwdocd
40534053
4054- def scatter_classic (self , x , y , s = None , c = 'b' ):
4055- """
4056- scatter_classic is no longer available; please use scatter.
4057- To help in porting, for comparison to the scatter docstring,
4058- here is the scatter_classic docstring:
4059-
4060- SCATTER_CLASSIC(x, y, s=None, c='b')
4061-
4062- Make a scatter plot of x versus y. s is a size (in data coords) and
4063- can be either a scalar or an array of the same length as x or y. c is
4064- a color and can be a single color format string or an length(x) array
4065- of intensities which will be mapped by the colormap jet.
4066-
4067- If size is None a default size will be used
4068- """
4069- raise NotImplementedError ('scatter_classic has been removed;\n '
4070- + 'please use scatter instead' )
4071-
4072- def pcolor_classic (self , * args ):
4073- """
4074- pcolor_classic is no longer available; please use pcolor,
4075- which is a drop-in replacement.
4076- """
4077- raise NotImplementedError ('pcolor_classic has been removed;\n '
4078- + 'please use pcolor instead' )
4079-
4080-
4081-
40824054 def arrow (self , x , y , dx , dy , ** kwargs ):
40834055 """
40844056 Draws arrow on specified axis from (x,y) to (x+dx,y+dy).
@@ -4097,164 +4069,14 @@ def quiverkey(self, *args, **kw):
40974069 return qk
40984070 quiverkey .__doc__ = mquiver .QuiverKey .quiverkey_doc
40994071
4100- def quiver2 (self , * args , ** kw ):
4072+ def quiver (self , * args , ** kw ):
41014073 q = mquiver .Quiver (self , * args , ** kw )
41024074 self .add_collection (q )
41034075 self .update_datalim_numerix (q .X , q .Y )
41044076 self .autoscale_view ()
41054077 return q
4106- quiver2 .__doc__ = mquiver .Quiver .quiver_doc
4107-
4108- def quiver (self , * args , ** kw ):
4109- if (len (args ) == 3 or len (args ) == 5 ) and not iterable (args [- 1 ]):
4110- return self .quiver_classic (* args , ** kw )
4111- c = kw .get ('color' , None )
4112- if c is not None :
4113- if not mcolors .is_color_like (c ):
4114- assert npy .shape (npy .asarray (c )) == npy .shape (npy .asarray (args [- 1 ]))
4115- return self .quiver_classic (* args , ** kw )
4116- return self .quiver2 (* args , ** kw )
41174078 quiver .__doc__ = mquiver .Quiver .quiver_doc
41184079
4119- def quiver_classic (self , U , V , * args , ** kwargs ):
4120- """
4121- QUIVER( X, Y, U, V )
4122- QUIVER( U, V )
4123- QUIVER( X, Y, U, V, S)
4124- QUIVER( U, V, S )
4125- QUIVER( ..., color=None, width=1.0, cmap=None, norm=None )
4126-
4127- Make a vector plot (U, V) with arrows on a grid (X, Y)
4128-
4129- If X and Y are not specified, U and V must be 2D arrays.
4130- Equally spaced X and Y grids are then generated using the
4131- meshgrid command.
4132-
4133- color can be a color value or an array of colors, so that the
4134- arrows can be colored according to another dataset. If cmap
4135- is specified and color is 'length', the colormap is used to
4136- give a color according to the vector's length.
4137-
4138- If color is a scalar field, the colormap is used to map the
4139- scalar to a color If a colormap is specified and color is an
4140- array of color triplets, then the colormap is ignored
4141-
4142- width is a scalar that controls the width of the arrows
4143-
4144- if S is specified it is used to scale the vectors. Use S=0 to
4145- disable automatic scaling. If S!=0, vectors are scaled to fit
4146- within the grid and then are multiplied by S.
4147-
4148-
4149- """
4150- msg = '''This version of quiver is obsolete and will be
4151- phased out; please use the new quiver.
4152- '''
4153- warnings .warn (msg , DeprecationWarning )
4154- if not self ._hold : self .cla ()
4155- do_scale = True
4156- S = 1.0
4157- if len (args )== 0 :
4158- # ( U, V )
4159- U = npy .asarray (U )
4160- V = npy .asarray (V )
4161- X ,Y = mlab .meshgrid ( npy .arange (U .shape [1 ]), npy .arange (U .shape [0 ]) )
4162- elif len (args )== 1 :
4163- # ( U, V, S )
4164- U = npy .asarray (U )
4165- V = npy .asarray (V )
4166- X ,Y = mlab .meshgrid ( npy .arange (U .shape [1 ]), npy .arange (U .shape [0 ]) )
4167- S = float (args [0 ])
4168- do_scale = ( S != 0.0 )
4169- elif len (args )== 2 :
4170- # ( X, Y, U, V )
4171- X = npy .asarray (U )
4172- Y = npy .asarray (V )
4173- U = npy .asarray (args [0 ])
4174- V = npy .asarray (args [1 ])
4175- elif len (args )== 3 :
4176- # ( X, Y, U, V )
4177- X = npy .asarray (U )
4178- Y = npy .asarray (V )
4179- U = npy .asarray (args [0 ])
4180- V = npy .asarray (args [1 ])
4181- S = float (args [2 ])
4182- do_scale = ( S != 0.0 )
4183-
4184- assert U .shape == V .shape
4185- assert X .shape == Y .shape
4186- assert U .shape == X .shape
4187-
4188- U = U .ravel ()
4189- V = V .ravel ()
4190- X = X .ravel ()
4191- Y = Y .ravel ()
4192-
4193- arrows = []
4194- N = npy .sqrt ( U ** 2 + V ** 2 )
4195- if do_scale :
4196- Nmax = maximum .reduce (N ) or 1 # account for div by zero
4197- U = U * (S / Nmax )
4198- V = V * (S / Nmax )
4199- N = N * Nmax
4200-
4201- alpha = kwargs .pop ('alpha' , 1.0 )
4202- width = kwargs .pop ('width' , .5 )
4203- norm = kwargs .pop ('norm' , None )
4204- cmap = kwargs .pop ('cmap' , None )
4205- vmin = kwargs .pop ('vmin' , None )
4206- vmax = kwargs .pop ('vmax' , None )
4207- color = kwargs .pop ('color' , None )
4208- shading = kwargs .pop ('shading' , 'faceted' )
4209-
4210- if len (kwargs ):
4211- raise TypeError (
4212- "quiver() got an unexpected keyword argument '%s'" % kwargs .keys ()[0 ])
4213-
4214- C = None
4215- if color == 'length' or color is True :
4216- if color is True :
4217- warnings .warn ('''Use "color='length'",
4218- not "color=True"''' , DeprecationWarning )
4219- C = N
4220- elif color is None :
4221- color = (0 ,0 ,0 ,1 )
4222- else :
4223- clr = npy .asarray (color ).ravel ()
4224- if clr .shape == U .shape :
4225- C = clr
4226-
4227- I = U .shape [0 ]
4228- arrows = [mpatches .FancyArrow (X [i ],Y [i ],U [i ],V [i ],0.1 * S ).get_verts ()
4229- for i in xrange (I )]
4230-
4231- collection = mcoll .PolyCollection (
4232- arrows ,
4233- edgecolors = 'None' ,
4234- antialiaseds = (1 ,),
4235- linewidths = (width ,),
4236- )
4237- if C is not None :
4238- collection .set_array ( C .ravel () )
4239- collection .set_cmap (cmap )
4240- collection .set_norm (norm )
4241- if norm is not None :
4242- collection .set_clim ( vmin , vmax )
4243- else :
4244- collection .set_facecolor (color )
4245- self .add_collection ( collection )
4246-
4247- lims = npy .asarray (arrows )
4248- _max = maximum .reduce ( maximum .reduce ( lims ))
4249- _min = minimum .reduce ( minimum .reduce ( lims ))
4250- self .update_datalim ( [ tuple (_min ), tuple (_max ) ] )
4251- self .autoscale_view ()
4252- return collection
4253-
4254-
4255-
4256-
4257-
42584080 def fill (self , * args , ** kwargs ):
42594081 """
42604082 FILL(*args, **kwargs)
0 commit comments