You can subscribe to this list here.
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(115) |
Aug
(120) |
Sep
(137) |
Oct
(170) |
Nov
(461) |
Dec
(263) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
(120) |
Feb
(74) |
Mar
(35) |
Apr
(74) |
May
(245) |
Jun
(356) |
Jul
(240) |
Aug
(115) |
Sep
(78) |
Oct
(225) |
Nov
(98) |
Dec
(271) |
2009 |
Jan
(132) |
Feb
(84) |
Mar
(74) |
Apr
(56) |
May
(90) |
Jun
(79) |
Jul
(83) |
Aug
(296) |
Sep
(214) |
Oct
(76) |
Nov
(82) |
Dec
(66) |
2010 |
Jan
(46) |
Feb
(58) |
Mar
(51) |
Apr
(77) |
May
(58) |
Jun
(126) |
Jul
(128) |
Aug
(64) |
Sep
(50) |
Oct
(44) |
Nov
(48) |
Dec
(54) |
2011 |
Jan
(68) |
Feb
(52) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
2018 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
S | M | T | W | T | F | S |
---|---|---|---|---|---|---|
|
|
1
(3) |
2
(2) |
3
(5) |
4
(1) |
5
|
6
|
7
(6) |
8
(3) |
9
(7) |
10
(6) |
11
(14) |
12
(6) |
13
(10) |
14
(6) |
15
|
16
|
17
(15) |
18
(6) |
19
(1) |
20
(4) |
21
(8) |
22
(9) |
23
(12) |
24
(35) |
25
(21) |
26
(14) |
27
(11) |
28
(9) |
29
(11) |
30
(6) |
31
(9) |
|
|
Revision: 5866 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5866&view=rev Author: pkienzle Date: 2008年07月25日 05:01:18 +0000 (2008年7月25日) Log Message: ----------- mouse wheel support for tk backend Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/backends/backend_tkagg.py Modified: trunk/matplotlib/lib/matplotlib/backends/backend_tkagg.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_tkagg.py 2008年07月25日 03:55:16 UTC (rev 5865) +++ trunk/matplotlib/lib/matplotlib/backends/backend_tkagg.py 2008年07月25日 05:01:18 UTC (rev 5866) @@ -164,10 +164,19 @@ self._tkcanvas.bind("<KeyRelease>", self.key_release) for name in "<Button-1>", "<Button-2>", "<Button-3>": self._tkcanvas.bind(name, self.button_press_event) - for name in "<ButtonRelease-1>", "<ButtonRelease-2>", "<ButtonRelease-3>": self._tkcanvas.bind(name, self.button_release_event) + # Mouse wheel on Linux generates button 4/5 events + for name in "<Button-4>", "<Button-5>": + self._tkcanvas.bind(name, self.scroll_event) + # Mouse wheel for windows goes to the window with the focus. + # Since the canvas won't usually have the focus, bind the + # event to the window containing the canvas instead. + # See http://wiki.tcl.tk/3893 (mousewheel) for details + root = self._tkcanvas.winfo_toplevel() + root.bind("<MouseWheel>", self.scroll_event_windows) + self._master = master self._tkcanvas.focus_set() @@ -265,6 +274,26 @@ FigureCanvasBase.button_release_event(self, x, y, num, guiEvent=event) + def scroll_event(self, event): + x = event.x + y = self.figure.bbox.height - event.y + num = getattr(event, 'num', None) + if num==4: step = -1 + elif num==5: step = +1 + else: step = 0 + + FigureCanvasBase.scroll_event(self, x, y, step, guiEvent=event) + + def scroll_event_windows(self, event): + """MouseWheel event processor""" + # need to find the window that contains the mouse + w = event.widget.winfo_containing(event.x_root, event.y_root) + if w == self._tkcanvas: + x = event.x_root - w.winfo_rootx() + y = event.y_root - w.winfo_rooty() + step = event.delta/120. + FigureCanvasBase.scroll_event(self, x, y, step, guiEvent=event) + def _get_key(self, event): val = event.keysym_num if self.keyvald.has_key(val): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5865 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5865&view=rev Author: efiring Date: 2008年07月25日 03:55:16 +0000 (2008年7月25日) Log Message: ----------- Fix quiverkey with coordinates="inches". Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/quiver.py Modified: trunk/matplotlib/lib/matplotlib/quiver.py =================================================================== --- trunk/matplotlib/lib/matplotlib/quiver.py 2008年07月25日 03:53:18 UTC (rev 5864) +++ trunk/matplotlib/lib/matplotlib/quiver.py 2008年07月25日 03:55:16 UTC (rev 5865) @@ -289,10 +289,7 @@ elif self.coord == 'figure': self.set_transform(self.Q.ax.figure.transFigure) elif self.coord == 'inches': - dx = ax.figure.dpi - bb = transforms.Bbox.from_extents(0, 0, dx, dy) - trans = transforms.BboxTransformTo(bb) - self.set_transform(trans) + self.set_transform(self.Q.ax.figure.dpi_scale_trans) else: raise ValueError('unrecognized coordinates') quiverkey_doc = _quiverkey_doc This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5864 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5864&view=rev Author: efiring Date: 2008年07月25日 03:53:18 +0000 (2008年7月25日) Log Message: ----------- Fix quiver whitespace Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/quiver.py Modified: trunk/matplotlib/lib/matplotlib/quiver.py =================================================================== --- trunk/matplotlib/lib/matplotlib/quiver.py 2008年07月25日 03:41:21 UTC (rev 5863) +++ trunk/matplotlib/lib/matplotlib/quiver.py 2008年07月25日 03:53:18 UTC (rev 5864) @@ -5,8 +5,8 @@ direction of the vector, with the size of the arrow related to the magnitude of the vector. -Barbs are like quiver in that they point along a vector, but -the magnitude of the vector is given schematically by the presence of barbs +Barbs are like quiver in that they point along a vector, but +the magnitude of the vector is given schematically by the presence of barbs or flags on the barb. This will also become a home for things such as standard @@ -23,7 +23,7 @@ import matplotlib.artist as martist import matplotlib.font_manager as font_manager from matplotlib.cbook import delete_masked_points -from matplotlib.patches import CirclePolygon +from matplotlib.patches import CirclePolygon import math @@ -506,63 +506,63 @@ quiver_doc = _quiver_doc -_barbs_doc = """ -Plot a 2-D field of barbs. - -call signatures:: - - barb(U, V, **kw) - barb(U, V, C, **kw) - barb(X, Y, U, V, **kw) - barb(X, Y, U, V, C, **kw) - -Arguments: - - *X*, *Y*: - The x and y coordinates of the barb locations - (default is head of barb; see *pivot* kwarg) - - *U*, *V*: - give the *x* and *y* components of the barb shaft - - *C*: - an optional array used to map colors to the barbs - -All arguments may be 1-D or 2-D arrays or sequences. If *X* and *Y* -are absent, they will be generated as a uniform grid. If *U* and *V* -are 2-D arrays but *X* and *Y* are 1-D, and if len(*X*) and len(*Y*) -match the column and row dimensions of *U*, then *X* and *Y* will be -expanded with :func:`numpy.meshgrid`. - -*U*, *V*, *C* may be masked arrays, but masked *X*, *Y* are not -supported at present. - -Keyword arguments: - - *length*: - Length of the barb in points; the other parts of the barb - are scaled against this. - Default is 9 - - *pivot*: [ 'tip' | 'middle' ] - The part of the arrow that is at the grid point; the arrow +_barbs_doc = """ +Plot a 2-D field of barbs. + +call signatures:: + + barb(U, V, **kw) + barb(U, V, C, **kw) + barb(X, Y, U, V, **kw) + barb(X, Y, U, V, C, **kw) + +Arguments: + + *X*, *Y*: + The x and y coordinates of the barb locations + (default is head of barb; see *pivot* kwarg) + + *U*, *V*: + give the *x* and *y* components of the barb shaft + + *C*: + an optional array used to map colors to the barbs + +All arguments may be 1-D or 2-D arrays or sequences. If *X* and *Y* +are absent, they will be generated as a uniform grid. If *U* and *V* +are 2-D arrays but *X* and *Y* are 1-D, and if len(*X*) and len(*Y*) +match the column and row dimensions of *U*, then *X* and *Y* will be +expanded with :func:`numpy.meshgrid`. + +*U*, *V*, *C* may be masked arrays, but masked *X*, *Y* are not +supported at present. + +Keyword arguments: + + *length*: + Length of the barb in points; the other parts of the barb + are scaled against this. + Default is 9 + + *pivot*: [ 'tip' | 'middle' ] + The part of the arrow that is at the grid point; the arrow rotates about this point, hence the name *pivot*. - Default is 'tip' - - *barbcolor*: [ color | color sequence ] - Specifies the color all parts of the barb except any flags. - This parameter is analagous to the *edgecolor* parameter - for polygons, which can be used instead. However this parameter - will override facecolor. - - *flagcolor*: [ color | color sequence ] - Specifies the color of any flags on the barb. - This parameter is analagous to the *facecolor* parameter - for polygons, which can be used instead. However this parameter - will override facecolor. If this is not set (and *C* has not either) - then *flagcolor* will be set to match *barbcolor* so that the barb - has a uniform color. If *C* has been set, *flagcolor* has no effect. - + Default is 'tip' + + *barbcolor*: [ color | color sequence ] + Specifies the color all parts of the barb except any flags. + This parameter is analagous to the *edgecolor* parameter + for polygons, which can be used instead. However this parameter + will override facecolor. + + *flagcolor*: [ color | color sequence ] + Specifies the color of any flags on the barb. + This parameter is analagous to the *facecolor* parameter + for polygons, which can be used instead. However this parameter + will override facecolor. If this is not set (and *C* has not either) + then *flagcolor* will be set to match *barbcolor* so that the barb + has a uniform color. If *C* has been set, *flagcolor* has no effect. + *sizes*: A dictionary of coefficients specifying the ratio of a given feature to the length of the barb. Only those values one wishes to override @@ -576,7 +576,7 @@ A flag on whether the empty barbs (circles) that are drawn should be filled with the flag color. If they are not filled, they will be drawn such that no color is applied to the center. - Default is False + Default is False *rounding*: A flag to indicate whether the vector magnitude should be rounded when @@ -588,7 +588,7 @@ *barb_increments*: A dictionary of increments specifying values to associate with different parts of the barb. Only those values one wishes to override need to be - included. + included. 'half' - half barbs (Default is 5) 'full' - full barbs (Default is 10) 'flag' - flags (default is 50) @@ -602,66 +602,66 @@ wind barbs having these features point towards low pressure in the Northern Hemisphere.) Default is False - -Barbs are traditionally used in meteorology as a way to plot the speed -and direction of wind observations, but can technically be used to plot -any two dimensional vector quantity. As opposed to arrows, which give -vector magnitude by the length of the arrow, the barbs give more quantitative -information about the vector magnitude by putting slanted lines or a triangle -for various increments in magnitude, as show schematically below: - - /\ \ - / \ \ - / \ \ \ -/ \ \ \ ------------------------------- - + +Barbs are traditionally used in meteorology as a way to plot the speed +and direction of wind observations, but can technically be used to plot +any two dimensional vector quantity. As opposed to arrows, which give +vector magnitude by the length of the arrow, the barbs give more quantitative +information about the vector magnitude by putting slanted lines or a triangle +for various increments in magnitude, as show schematically below: + + /\ \ + / \ \ + / \ \ \ +/ \ \ \ +------------------------------ + The largest increment is given by a triangle (or "flag"). After those come full -lines (barbs). The smallest increment is a half line. There is only, of -course, ever at most 1 half line. If the magnitude is small and only needs a -single half-line and no full lines or triangles, the half-line is offset from -the end of the barb so that it can be easily distinguished from barbs with a -single full line. The magnitude for the barb shown above would nominally be -65, using the standard increments of 50, 10, and 5. - -linewidths and edgecolors can be used to customize the barb. -Additional :class:`~matplotlib.collections.PolyCollection` -keyword arguments: - -%(PolyCollection)s -""" % martist.kwdocd +lines (barbs). The smallest increment is a half line. There is only, of +course, ever at most 1 half line. If the magnitude is small and only needs a +single half-line and no full lines or triangles, the half-line is offset from +the end of the barb so that it can be easily distinguished from barbs with a +single full line. The magnitude for the barb shown above would nominally be +65, using the standard increments of 50, 10, and 5. -class Barbs(collections.PolyCollection): - ''' - Specialized PolyCollection for barbs. - +linewidths and edgecolors can be used to customize the barb. +Additional :class:`~matplotlib.collections.PolyCollection` +keyword arguments: + +%(PolyCollection)s +""" % martist.kwdocd + +class Barbs(collections.PolyCollection): + ''' + Specialized PolyCollection for barbs. + The only API method is set_UVC(), which can be used to change the size, orientation, and color of the arrows. Locations are changed using the set_offsets() collection method.Possibly this method will be useful in animations. - - There is one internal function _find_tails() which finds exactly - what should be put on the barb given the vector magnitude. From there - _make_barbs() is used to find the vertices of the polygon to represent the - barb based on this information. - ''' - #This may be an abuse of polygons here to render what is essentially maybe - #1 triangle and a series of lines. It works fine as far as I can tell - #however. - def __init__(self, ax, *args, **kw): - self._pivot = kw.pop('pivot', 'tip') - self._length = kw.pop('length', 7) - barbcolor = kw.pop('barbcolor', None) - flagcolor = kw.pop('flagcolor', None) + + There is one internal function _find_tails() which finds exactly + what should be put on the barb given the vector magnitude. From there + _make_barbs() is used to find the vertices of the polygon to represent the + barb based on this information. + ''' + #This may be an abuse of polygons here to render what is essentially maybe + #1 triangle and a series of lines. It works fine as far as I can tell + #however. + def __init__(self, ax, *args, **kw): + self._pivot = kw.pop('pivot', 'tip') + self._length = kw.pop('length', 7) + barbcolor = kw.pop('barbcolor', None) + flagcolor = kw.pop('flagcolor', None) self.sizes = kw.pop('sizes', dict()) self.fill_empty = kw.pop('fill_empty', False) self.barb_increments = kw.pop('barb_increments', dict()) self.rounding = kw.pop('rounding', True) self.flip = kw.pop('flip_barb', False) - #Flagcolor and and barbcolor provide convenience parameters for setting - #the facecolor and edgecolor, respectively, of the barb polygon. We - #also work here to make the flag the same color as the rest of the barb + #Flagcolor and and barbcolor provide convenience parameters for setting + #the facecolor and edgecolor, respectively, of the barb polygon. We + #also work here to make the flag the same color as the rest of the barb #by default if None in (barbcolor, flagcolor): kw['edgecolors'] = 'face' @@ -671,109 +671,109 @@ kw['facecolors'] = barbcolor else: #Set to facecolor passed in or default to black - kw.setdefault('facecolors', 'k') + kw.setdefault('facecolors', 'k') else: kw['edgecolors'] = barbcolor kw['facecolors'] = flagcolor - - #Parse out the data arrays from the various configurations supported + + #Parse out the data arrays from the various configurations supported x, y, u, v, c = self._parse_args(*args) self.x = x - self.y = y - xy = np.hstack((x[:,np.newaxis], y[:,np.newaxis])) + self.y = y + xy = np.hstack((x[:,np.newaxis], y[:,np.newaxis])) - #Make a collection + #Make a collection barb_size = self._length**2 / 4 #Empirically determined collections.PolyCollection.__init__(self, [], (barb_size,), offsets=xy, - transOffset=ax.transData, **kw) - self.set_transform(transforms.IdentityTransform()) + transOffset=ax.transData, **kw) + self.set_transform(transforms.IdentityTransform()) self.set_UVC(u, v, c) - - __init__.__doc__ = """ - The constructor takes one required argument, an Axes - instance, followed by the args and kwargs described - by the following pylab interface documentation: - %s""" % _barbs_doc - - def _find_tails(self, mag, rounding=True, half=5, full=10, flag=50): + + __init__.__doc__ = """ + The constructor takes one required argument, an Axes + instance, followed by the args and kwargs described + by the following pylab interface documentation: + %s""" % _barbs_doc + + def _find_tails(self, mag, rounding=True, half=5, full=10, flag=50): '''Find how many of each of the tail pieces is necessary. Flag specifies the increment for a flag, barb for a full barb, and half for - half a barb. Mag should be the magnitude of a vector (ie. >= 0). - - This returns a tuple of: - (number of flags, number of barbs, half_flag, empty_flag) - half_flag is a boolean whether half of a barb is needed, since there + half a barb. Mag should be the magnitude of a vector (ie. >= 0). + + This returns a tuple of: + (number of flags, number of barbs, half_flag, empty_flag) + half_flag is a boolean whether half of a barb is needed, since there should only ever be one half on a given barb. Empty flag is an array of flags to easily tell if a barb is empty (too low to plot any - barbs/flags.''' + barbs/flags.''' #If rounding, round to the nearest multiple of half, the smallest #increment if rounding: mag = half * (mag / half + 0.5).astype(np.int) - - num_flags = np.floor(mag / flag).astype(np.int) - mag = np.mod(mag, flag) - - num_barb = np.floor(mag / full).astype(np.int) - mag = np.mod(mag, full) - + + num_flags = np.floor(mag / flag).astype(np.int) + mag = np.mod(mag, flag) + + num_barb = np.floor(mag / full).astype(np.int) + mag = np.mod(mag, full) + half_flag = mag >= half empty_flag = ~(half_flag | (num_flags > 0) | (num_barb > 0)) - - return num_flags, num_barb, half_flag, empty_flag - + + return num_flags, num_barb, half_flag, empty_flag + def _make_barbs(self, u, v, nflags, nbarbs, half_barb, empty_flag, length, - pivot, sizes, fill_empty, flip): + pivot, sizes, fill_empty, flip): '''This function actually creates the wind barbs. u and v are components of the vector in the x and y directions, respectively. nflags, nbarbs, and half_barb, empty_flag are, respectively, the number of flags, number of barbs, flag for half a barb, and flag for empty - barb, ostensibly obtained from _find_tails. length is the length of - the barb staff in points. pivot specifies the point on the barb around - which the entire barb should be rotated. Right now valid options are + barb, ostensibly obtained from _find_tails. length is the length of + the barb staff in points. pivot specifies the point on the barb around + which the entire barb should be rotated. Right now valid options are 'head' and 'middle'. sizes is a dictionary of coefficients specifying the ratio of a given feature to the length of the barb. These features include: - + spacing - space between features (flags, full/half barbs) height - height (distance from shaft of top) of a flag or full barb width - width of a flag, twice the width of a full barb - emptybarb - radius of the circle used for low magnitudes - + emptybarb - radius of the circle used for low magnitudes + fill_empty specifies whether the circle representing an empty barb should be filled or not (this changes the drawing of the polygon). flip is a flag indicating whether the features should be flipped to the other side of the barb (useful for winds in the southern hemisphere. - - This function returns list of arrays of vertices, defining a polygon for - each of the wind barbs. These polygons have been rotated to properly + + This function returns list of arrays of vertices, defining a polygon for + each of the wind barbs. These polygons have been rotated to properly align with the vector direction.''' - - #These control the spacing and size of barb elements relative to the - #length of the shaft - spacing = length * sizes.get('spacing', 0.125) - full_height = length * sizes.get('height', 0.4) + + #These control the spacing and size of barb elements relative to the + #length of the shaft + spacing = length * sizes.get('spacing', 0.125) + full_height = length * sizes.get('height', 0.4) full_width = length * sizes.get('width', 0.25) - empty_rad = length * sizes.get('emptybarb', 0.15) - - #Controls y point where to pivot the barb. - pivot_points = dict(tip=0.0, middle=-length/2.) + empty_rad = length * sizes.get('emptybarb', 0.15) + #Controls y point where to pivot the barb. + pivot_points = dict(tip=0.0, middle=-length/2.) + #Check for flip if flip: full_height = -full_height - - endx = 0.0 - endy = pivot_points[pivot.lower()] - - #Get the appropriate angle for the vector components. The offset is due - #to the way the barb is initially drawn, going down the y-axis. This - #makes sense in a meteorological mode of thinking since there 0 degrees - #corresponds to north (the y-axis traditionally) - angles = -(ma.arctan2(v, u) + np.pi/2) - + + endx = 0.0 + endy = pivot_points[pivot.lower()] + + #Get the appropriate angle for the vector components. The offset is due + #to the way the barb is initially drawn, going down the y-axis. This + #makes sense in a meteorological mode of thinking since there 0 degrees + #corresponds to north (the y-axis traditionally) + angles = -(ma.arctan2(v, u) + np.pi/2) + #Used for low magnitude. We just get the vertices, so if we make it #out here, it can be reused. The center set here should put the #center of the circle at the location(offset), rather than at the @@ -784,7 +784,7 @@ else: #If we don't want the empty one filled, we make a degenerate polygon #that wraps back over itself - empty_barb = np.concatenate((circ, circ[::-1])) + empty_barb = np.concatenate((circ, circ[::-1])) barb_list = [] for index, angle in np.ndenumerate(angles): @@ -795,77 +795,77 @@ #orientation barb_list.append(empty_barb) continue - - poly_verts = [(endx, endy)] - offset = length - - #Add vertices for each flag - for i in range(nflags[index]): + + poly_verts = [(endx, endy)] + offset = length + + #Add vertices for each flag + for i in range(nflags[index]): #The spacing that works for the barbs is a little to much for - #the flags, but this only occurs when we have more than 1 flag. - if offset != length: offset += spacing / 2. - poly_verts.extend([[endx, endy + offset], - [endx + full_height, endy - full_width/2 + offset], - [endx, endy - full_width + offset]]) - - offset -= full_width + spacing - + #the flags, but this only occurs when we have more than 1 flag. + if offset != length: offset += spacing / 2. + poly_verts.extend([[endx, endy + offset], + [endx + full_height, endy - full_width/2 + offset], + [endx, endy - full_width + offset]]) + + offset -= full_width + spacing + #Add vertices for each barb. These really are lines, but works #great adding 3 vertices that basically pull the polygon out and - #back down the line - for i in range(nbarbs[index]): - poly_verts.extend([(endx, endy + offset), - (endx + full_height, endy + offset + full_width/2), - (endx, endy + offset)]) - - offset -= spacing - - #Add the vertices for half a barb, if needed - if half_barb[index]: - #If the half barb is the first on the staff, traditionally it is - #offset from the end to make it easy to distinguish from a barb - #with a full one - if offset == length: - poly_verts.append((endx, endy + offset)) - offset -= 1.5 * spacing - poly_verts.extend([(endx, endy + offset), - (endx + full_height/2, endy + offset + full_width/4), - (endx, endy + offset)]) - - #Rotate the barb according the angle. Making the barb first and then - #rotating it made the math for drawing the barb really easy. Also, - #the transform framework makes doing the rotation simple. + #back down the line + for i in range(nbarbs[index]): + poly_verts.extend([(endx, endy + offset), + (endx + full_height, endy + offset + full_width/2), + (endx, endy + offset)]) + + offset -= spacing + + #Add the vertices for half a barb, if needed + if half_barb[index]: + #If the half barb is the first on the staff, traditionally it is + #offset from the end to make it easy to distinguish from a barb + #with a full one + if offset == length: + poly_verts.append((endx, endy + offset)) + offset -= 1.5 * spacing + poly_verts.extend([(endx, endy + offset), + (endx + full_height/2, endy + offset + full_width/4), + (endx, endy + offset)]) + + #Rotate the barb according the angle. Making the barb first and then + #rotating it made the math for drawing the barb really easy. Also, + #the transform framework makes doing the rotation simple. poly_verts = transforms.Affine2D().rotate(-angle).transform( - poly_verts) - barb_list.append(poly_verts) - - return barb_list - - #Taken shamelessly from Quiver - def _parse_args(self, *args): - X, Y, U, V, C = [None]*5 - args = list(args) - if len(args) == 3 or len(args) == 5: - C = ma.asarray(args.pop(-1)).ravel() - V = ma.asarray(args.pop(-1)) + poly_verts) + barb_list.append(poly_verts) + + return barb_list + + #Taken shamelessly from Quiver + def _parse_args(self, *args): + X, Y, U, V, C = [None]*5 + args = list(args) + if len(args) == 3 or len(args) == 5: + C = ma.asarray(args.pop(-1)).ravel() + V = ma.asarray(args.pop(-1)) U = ma.asarray(args.pop(-1)) - nn = np.shape(U) - nc = nn[0] - nr = 1 - if len(nn) > 1: - nr = nn[1] - if len(args) == 2: # remaining after removing U,V,C - X, Y = [np.array(a).ravel() for a in args] - if len(X) == nc and len(Y) == nr: - X, Y = [a.ravel() for a in np.meshgrid(X, Y)] - else: - indexgrid = np.meshgrid(np.arange(nc), np.arange(nr)) - X, Y = [np.ravel(a) for a in indexgrid] - return X, Y, U, V, C + nn = np.shape(U) + nc = nn[0] + nr = 1 + if len(nn) > 1: + nr = nn[1] + if len(args) == 2: # remaining after removing U,V,C + X, Y = [np.array(a).ravel() for a in args] + if len(X) == nc and len(Y) == nr: + X, Y = [a.ravel() for a in np.meshgrid(X, Y)] + else: + indexgrid = np.meshgrid(np.arange(nc), np.arange(nr)) + X, Y = [np.ravel(a) for a in indexgrid] + return X, Y, U, V, C def set_UVC(self, U, V, C=None): self.u = ma.asarray(U).ravel() - self.v = ma.asarray(V).ravel() + self.v = ma.asarray(V).ravel() if C is not None: c = ma.asarray(C).ravel() x,y,u,v,c = delete_masked_points(self.x.ravel(), self.y.ravel(), @@ -874,20 +874,20 @@ x,y,u,v = delete_masked_points(self.x.ravel(), self.y.ravel(), self.u, self.v) - magnitude = np.sqrt(u*u + v*v) + magnitude = np.sqrt(u*u + v*v) flags, barbs, halves, empty = self._find_tails(magnitude, - self.rounding, **self.barb_increments) - + self.rounding, **self.barb_increments) + #Get the vertices for each of the barbs - + plot_barbs = self._make_barbs(u, v, flags, barbs, halves, empty, self._length, self._pivot, self.sizes, self.fill_empty, self.flip) self.set_verts(plot_barbs) - + #Set the color array if C is not None: self.set_array(c) - + #Update the offsets in case the masked data changed xy = np.hstack((x[:,np.newaxis], y[:,np.newaxis])) self._offsets = xy @@ -897,7 +897,7 @@ Set the offsets for the barb polygons. This saves the offets passed in and actually sets version masked as appropriate for the existing U/V data. *offsets* should be a sequence. - + ACCEPTS: sequence of pairs of floats ''' self.x = xy[:,0] @@ -908,5 +908,4 @@ collections.PolyCollection.set_offsets(self, xy) set_offsets.__doc__ = collections.PolyCollection.set_offsets.__doc__ - barbs_doc = _barbs_doc - + barbs_doc = _barbs_doc This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5863 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5863&view=rev Author: efiring Date: 2008年07月25日 03:41:21 +0000 (2008年7月25日) Log Message: ----------- Removed body of unmasked_index_ranges from lines.py. This should have been part of changeset 5812. Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/lines.py Modified: trunk/matplotlib/lib/matplotlib/lines.py =================================================================== --- trunk/matplotlib/lib/matplotlib/lines.py 2008年07月25日 02:40:12 UTC (rev 5862) +++ trunk/matplotlib/lib/matplotlib/lines.py 2008年07月25日 03:41:21 UTC (rev 5863) @@ -17,60 +17,20 @@ from transforms import Affine2D, Bbox, TransformedPath from matplotlib import rcParams - # special-purpose marker identifiers: (TICKLEFT, TICKRIGHT, TICKUP, TICKDOWN, CARETLEFT, CARETRIGHT, CARETUP, CARETDOWN) = range(8) + # COVERAGE NOTE: Never called internally or from examples def unmasked_index_ranges(mask, compressed = True): - ''' - Calculate the good data ranges in a masked 1-D np.array, based on - mask. + warnings.warn("Import this directly from matplotlib.cbook", + DeprecationWarning) + # Warning added 2008年07月22日 + from matplotlib.cbook import unmasked_index_ranges as _unmasked_index_ranges + return _unmasked_index_ranges(mask, compressed=compressed) - Returns Nx2 :class:`numpy.array` with each row the start and stop - indices for slices of the compressed :class:`numpy.array` - corresponding to each of *N* uninterrupted runs of unmasked - values. If optional argument *compressed* is *False*, it returns - the start and stop indices into the original :class:`numpy.array`, - not the compressed :class:`numpy.array`. Returns *None* if there - are no unmasked values. - Example:: - - y = ma.array(np.arange(5), mask = [0,0,1,0,0]) - #ii = unmasked_index_ranges(y.mask()) - ii = unmasked_index_ranges(ma.getmask(y)) - # returns [[0,2,] [2,4,]] - - y.compressed().filled()[ii[1,0]:ii[1,1]] - # returns np.array [3,4,] - # (The 'filled()' method converts the masked np.array to a numerix np.array.) - - #i0, i1 = unmasked_index_ranges(y.mask(), compressed=False) - i0, i1 = unmasked_index_ranges(ma.getmask(y), compressed=False) - # returns [[0,3,] [2,5,]] - - y.filled()[ii[1,0]:ii[1,1]] - # returns np.array [3,4,] - - ''' - m = np.concatenate(((1,), mask, (1,))) - indices = np.arange(len(mask) + 1) - mdif = m[1:] - m[:-1] - i0 = np.compress(mdif == -1, indices) - i1 = np.compress(mdif == 1, indices) - assert len(i0) == len(i1) - if len(i1) == 0: - return None - if not compressed: - return np.concatenate((i0[:, np.newaxis], i1[:, np.newaxis]), axis=1) - seglengths = i1 - i0 - breakpoints = np.cumsum(seglengths) - ic0 = np.concatenate(((0,), breakpoints[:-1])) - ic1 = breakpoints - return np.concatenate((ic0[:, np.newaxis], ic1[:, np.newaxis]), axis=1) - def segment_hits(cx,cy,x,y,radius): """Determine if any line segments are within radius of a point. Returns the list of line segments that are within that radius. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5862 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5862&view=rev Author: jswhit Date: 2008年07月25日 02:40:12 +0000 (2008年7月25日) Log Message: ----------- flip wind barbs for points in SH according to meterological convention. Modified Paths: -------------- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py =================================================================== --- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2008年07月25日 01:43:43 UTC (rev 5861) +++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2008年07月25日 02:40:12 UTC (rev 5862) @@ -2914,8 +2914,15 @@ h = kwargs.pop('hold',None) if h is not None: ax.hold(h) + lons, lats = self(x, y, inverse=True) + unh = ma.masked_where(lats <= 0, u) + vnh = ma.masked_where(lats <= 0, v) + ush = ma.masked_where(lats > 0, u) + vsh = ma.masked_where(lats > 0, v) try: - ret = ax.barbs(x,y,u,v,*args,**kwargs) + retnh = ax.barbs(x,y,unh,vnh,*args,**kwargs) + kwargs['flip_barb']=True + retsh = ax.barbs(x,y,ush,vsh,*args,**kwargs) try: plt.draw_if_interactive() except: @@ -2926,7 +2933,7 @@ ax.hold(b) # set axes limits to fit map region. self.set_axes_limits(ax=ax) - return ret + return retnh,retsh def drawlsmask(self,rgba_land,rgba_ocean,lsmask=None, lsmask_lons=None,lsmask_lats=None,lakes=False,**kwargs): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5861 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5861&view=rev Author: ryanmay Date: 2008年07月25日 01:43:43 +0000 (2008年7月25日) Log Message: ----------- Add support for flipping which side of the barb the features are drawn. Useful to the meteorologists in the southern hemisphere plus anyone who might have an aesthetic preference. Modified Paths: -------------- trunk/matplotlib/examples/pylab_examples/barb_demo.py trunk/matplotlib/lib/matplotlib/quiver.py Modified: trunk/matplotlib/examples/pylab_examples/barb_demo.py =================================================================== --- trunk/matplotlib/examples/pylab_examples/barb_demo.py 2008年07月24日 22:50:41 UTC (rev 5860) +++ trunk/matplotlib/examples/pylab_examples/barb_demo.py 2008年07月25日 01:43:43 UTC (rev 5861) @@ -36,6 +36,7 @@ #Change colors as well as the increments for parts of the barbs ax = plt.subplot(2,2,4) ax.barbs(data['x'], data['y'], data['u'], data['v'], flagcolor='r', - barbcolor=['b','g'], barb_increments=dict(half=10, full=20, flag=100)) + barbcolor=['b','g'], barb_increments=dict(half=10, full=20, flag=100), + flip_barb=True) plt.show() Modified: trunk/matplotlib/lib/matplotlib/quiver.py =================================================================== --- trunk/matplotlib/lib/matplotlib/quiver.py 2008年07月24日 22:50:41 UTC (rev 5860) +++ trunk/matplotlib/lib/matplotlib/quiver.py 2008年07月25日 01:43:43 UTC (rev 5861) @@ -592,6 +592,16 @@ 'half' - half barbs (Default is 5) 'full' - full barbs (Default is 10) 'flag' - flags (default is 50) + + *flip_barb*: + Either a single boolean flag or an array of booleans. Single boolean + indicates whether the lines and flags should point opposite to normal + for all barbs. An array (which should be the same size as the other + data arrays) indicates whether to flip for each individual barb. + Normal behavior is for the barbs and lines to point right (comes from + wind barbs having these features point towards low pressure in the + Northern Hemisphere.) + Default is False Barbs are traditionally used in meteorology as a way to plot the speed and direction of wind observations, but can technically be used to plot @@ -647,7 +657,8 @@ self.fill_empty = kw.pop('fill_empty', False) self.barb_increments = kw.pop('barb_increments', dict()) self.rounding = kw.pop('rounding', True) - + self.flip = kw.pop('flip_barb', False) + #Flagcolor and and barbcolor provide convenience parameters for setting #the facecolor and edgecolor, respectively, of the barb polygon. We #also work here to make the flag the same color as the rest of the barb @@ -714,7 +725,7 @@ return num_flags, num_barb, half_flag, empty_flag def _make_barbs(self, u, v, nflags, nbarbs, half_barb, empty_flag, length, - pivot, sizes, fill_empty): + pivot, sizes, fill_empty, flip): '''This function actually creates the wind barbs. u and v are components of the vector in the x and y directions, respectively. nflags, nbarbs, and half_barb, empty_flag are, respectively, the number @@ -730,7 +741,13 @@ height - height (distance from shaft of top) of a flag or full barb width - width of a flag, twice the width of a full barb emptybarb - radius of the circle used for low magnitudes - + + fill_empty specifies whether the circle representing an empty barb + should be filled or not (this changes the drawing of the polygon). + flip is a flag indicating whether the features should be flipped to + the other side of the barb (useful for winds in the southern + hemisphere. + This function returns list of arrays of vertices, defining a polygon for each of the wind barbs. These polygons have been rotated to properly align with the vector direction.''' @@ -744,6 +761,9 @@ #Controls y point where to pivot the barb. pivot_points = dict(tip=0.0, middle=-length/2.) + + #Check for flip + if flip: full_height = -full_height endx = 0.0 endy = pivot_points[pivot.lower()] @@ -861,7 +881,7 @@ #Get the vertices for each of the barbs plot_barbs = self._make_barbs(u, v, flags, barbs, halves, empty, - self._length, self._pivot, self.sizes, self.fill_empty) + self._length, self._pivot, self.sizes, self.fill_empty, self.flip) self.set_verts(plot_barbs) #Set the color array This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5860 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5860&view=rev Author: jdh2358 Date: 2008年07月24日 22:50:41 +0000 (2008年7月24日) Log Message: ----------- added wx simple animation example Modified Paths: -------------- trunk/matplotlib/examples/animation/simple_anim_gtk.py trunk/matplotlib/examples/animation/simple_anim_wx.py Modified: trunk/matplotlib/examples/animation/simple_anim_gtk.py =================================================================== --- trunk/matplotlib/examples/animation/simple_anim_gtk.py 2008年07月24日 22:49:38 UTC (rev 5859) +++ trunk/matplotlib/examples/animation/simple_anim_gtk.py 2008年07月24日 22:50:41 UTC (rev 5860) @@ -1,5 +1,5 @@ """ -A simple example of an animated plot using a gtk backends +A simple example of an animated plot using a gtk backend """ import time import numpy as np Modified: trunk/matplotlib/examples/animation/simple_anim_wx.py =================================================================== --- trunk/matplotlib/examples/animation/simple_anim_wx.py 2008年07月24日 22:49:38 UTC (rev 5859) +++ trunk/matplotlib/examples/animation/simple_anim_wx.py 2008年07月24日 22:50:41 UTC (rev 5860) @@ -1,5 +1,5 @@ """ -A simple example of an animated plot using a gtk backends +A simple example of an animated plot using a wx backend """ import time import numpy as np This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5859 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5859&view=rev Author: jdh2358 Date: 2008年07月24日 22:49:38 +0000 (2008年7月24日) Log Message: ----------- added wx simple animation example Added Paths: ----------- trunk/matplotlib/examples/animation/simple_anim_wx.py Added: trunk/matplotlib/examples/animation/simple_anim_wx.py =================================================================== --- trunk/matplotlib/examples/animation/simple_anim_wx.py (rev 0) +++ trunk/matplotlib/examples/animation/simple_anim_wx.py 2008年07月24日 22:49:38 UTC (rev 5859) @@ -0,0 +1,29 @@ +""" +A simple example of an animated plot using a gtk backends +""" +import time +import numpy as np +import matplotlib +matplotlib.use('WXAgg') # do this before importing pylab + +import matplotlib.pyplot as plt + +fig = plt.figure() + +ax = fig.add_subplot(111) + +def animate(idleevent): + tstart = time.time() # for profiling + x = np.arange(0, 2*np.pi, 0.01) # x-array + line, = ax.plot(x, np.sin(x)) + + for i in np.arange(1,200): + line.set_ydata(np.sin(x+i/10.0)) # update the data + fig.canvas.draw() # redraw the canvas + print 'FPS:' , 200/(time.time()-tstart) + raise SystemExit + +# call the animation loop on idle +import wx +wx.EVT_IDLE(wx.GetApp(), animate) +plt.show() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5858 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5858&view=rev Author: efiring Date: 2008年07月24日 22:44:55 +0000 (2008年7月24日) Log Message: ----------- Remove more obsolete files from unit subdirectory Removed Paths: ------------- trunk/matplotlib/unit/helpers.py trunk/matplotlib/unit/simple_plot.py trunk/matplotlib/unit/transform_memleak.py trunk/matplotlib/unit/transforms_unit.py Deleted: trunk/matplotlib/unit/helpers.py =================================================================== --- trunk/matplotlib/unit/helpers.py 2008年07月24日 22:41:52 UTC (rev 5857) +++ trunk/matplotlib/unit/helpers.py 2008年07月24日 22:44:55 UTC (rev 5858) @@ -1,23 +0,0 @@ -import sys, time, os -from matplotlib.numerix.mlab import rand -from matplotlib.transforms import identity_transform, unit_bbox, Func, IDENTITY -from matplotlib.transforms import one, Point, Value, Bbox, get_bbox_transform - - -def rand_val(N = 1): - if N==1: return Value(rand()) - else: return [Value(val) for val in rand(N)] - -def rand_point(): - return Point( rand_val(), rand_val() ) - -def rand_bbox(): - ll = rand_point() - ur = rand_point() - return Bbox(ll, ur) - -def rand_transform(): - b1 = rand_bbox() - b2 = rand_bbox() - return get_bbox_transform(b1, b2) - Deleted: trunk/matplotlib/unit/simple_plot.py =================================================================== --- trunk/matplotlib/unit/simple_plot.py 2008年07月24日 22:41:52 UTC (rev 5857) +++ trunk/matplotlib/unit/simple_plot.py 2008年07月24日 22:44:55 UTC (rev 5858) @@ -1,12 +0,0 @@ -import matplotlib -matplotlib.use('Template') -from pylab import * - -t = arange(0.0, 2.0, 0.01) -s = sin(2*pi*t) -plot(t, s) -xlabel('time (s)') -ylabel('voltage (mV)') -title('About as simple as it gets, folks') -savefig('simple_plot') -show() Deleted: trunk/matplotlib/unit/transform_memleak.py =================================================================== --- trunk/matplotlib/unit/transform_memleak.py 2008年07月24日 22:41:52 UTC (rev 5857) +++ trunk/matplotlib/unit/transform_memleak.py 2008年07月24日 22:44:55 UTC (rev 5858) @@ -1,37 +0,0 @@ -import sys, time, os -from helpers import rand_val, rand_point, rand_bbox, rand_transform -from matplotlib.numerix.mlab import rand - - -def report_memory(i): - pid = os.getpid() - if sys.platform=='sunos5': - command = 'ps -p %d -o rss,osz' % pid - else: - 'ps -p %d -o rss,sz' % pid - a2 = os.popen(command).readlines() - print i, ' ', a2[1], - return int(a2[1].split()[1]) - - -N = 200 -for i in range(N): - v1, v2, v3, v4, v5 = rand_val(5) - b1 = v1 + v2 - b2 = v3 -v4 - b3 = v1*v2*b2 - b1 - - - p1 = rand_point() - box1 = rand_bbox() - t = rand_transform() - N = 10000 - x, y = rand(N), rand(N) - xt, yt = t.numerix_x_y(x, y) - xys = t.seq_xy_tups( zip(x,y) ) - val = report_memory(i) - if i==1: start = val - -end = val -print 'Average memory consumed per loop: %1.4f\n' % ((end-start)/float(N)) - Deleted: trunk/matplotlib/unit/transforms_unit.py =================================================================== --- trunk/matplotlib/unit/transforms_unit.py 2008年07月24日 22:41:52 UTC (rev 5857) +++ trunk/matplotlib/unit/transforms_unit.py 2008年07月24日 22:44:55 UTC (rev 5858) @@ -1,305 +0,0 @@ -#from __future__ import division - -from matplotlib.numerix import array, asarray, alltrue, arange -from matplotlib.numerix.mlab import rand -from matplotlib.transforms import Point, Bbox, Value, Affine -from matplotlib.transforms import multiply_affines -from matplotlib.transforms import Func, IDENTITY, LOG10, POLAR, FuncXY -from matplotlib.transforms import SeparableTransformation -from matplotlib.transforms import identity_transform, unit_bbox -from matplotlib.transforms import get_bbox_transform -from matplotlib.transforms import transform_bbox, inverse_transform_bbox -from matplotlib.transforms import bbox_all -from matplotlib.transforms import copy_bbox_transform - - -def closeto(x,y): - return abs(asarray(x)-asarray(y))<1e-10 - -def closeto_seq(xs,ys): - return alltrue([closeto(x,y) for x,y in zip(xs, ys)]) - -def closeto_bbox(b1, b2): - xmin1, xmax1 = b1.intervalx().get_bounds() - ymin1, ymax1 = b1.intervaly().get_bounds() - xmin2, xmax2 = b2.intervalx().get_bounds() - ymin2, ymax2 = b2.intervaly().get_bounds() - - pairs = ( (xmin1, xmin2), (xmax1, xmax2), (ymin1, ymin2), (ymax1, ymax2)) - return alltrue([closeto(x,y) for x,y in pairs]) - -ll = Point( Value(10), Value(10) ) -ur = Point( Value(200), Value(40) ) - -bbox = Bbox(ll, ur) - -assert(bbox.xmin()==10) -assert(bbox.width()==190) -assert(bbox.height()==30) - -ll.x().set(12.0) -assert(bbox.xmin()==12) -assert(bbox.width()==188) -assert(bbox.height()==30) - - -a = Value(10) -b = Value(0) -c = Value(0) -d = Value(20) -tx = Value(-10) -ty = Value(-20) - -affine = Affine(a,b,c,d,tx,ty) -# test transformation of xy tuple -x, y = affine.xy_tup( (10,20) ) -assert(x==90) -assert(y==380) - -# test transformation of sequence of xy tuples -xy = affine.seq_xy_tups( ( (10,20), (20,30), ) ) -assert(xy[0] == (90, 380)) -assert(xy[1] == (190, 580)) - -# test transformation of x and y sequences -xy = affine.seq_x_y( (10,20), (20,30)) -assert(xy[0] == (90, 190)) -assert(xy[1] == (380, 580)) - -# test with numeric arrays -xy = affine.seq_x_y( array((10,20)), array((20,30))) -assert(xy[0] == (90, 190)) -assert(xy[1] == (380, 580)) - -# now change the x scale factor and make sure the affine updated -# properly -a.set(20) -xy = affine.seq_xy_tups( ( (10,20), (20,30), ) ) -assert(xy[0] == (190, 380)) -assert(xy[1] == (390, 580)) - -# Test the aritmetic operations on lazy values -v1 = Value(10) -v2 = Value(20) -o1 = v1 + v2 -assert( o1.get() == 30) - -o2 = v1 * v2 -assert( o2.get() == 200) - -v3 = Value(2) -o3 = (v1+v2)*v3 -assert( o3.get() == 60) - -# test a composition of affines -zero = Value(0) -one = Value(1) -two = Value(2) -num = Value(2) -a1 = Affine(num, zero, zero, num, zero, zero) -a2 = Affine(one, zero, zero, num, num, one ) - -pnt = 3,4 -a = multiply_affines(a1, a2) -assert( a2.xy_tup(pnt) == (5,9) ) -assert( a.xy_tup(pnt) == (10,18) ) - -a = multiply_affines(a2, a1) -assert( a1.xy_tup(pnt) == (6,8) ) -assert( a.xy_tup(pnt) == (8,17) ) - - -# change num to 4 and make sure the affine product is still right -num.set(4) -assert( a1.xy_tup(pnt) == (12,16) ) -assert( a.xy_tup(pnt) == (16,65) ) - -# test affines with arithemtic sums of lazy values -val = num*(one + two) -a1 = Affine(one, zero, zero, val, num, val) -assert(a1.xy_tup(pnt) == (7, 60)) - -x = rand(20) -y = rand(20) -transform = identity_transform() -xout, yout = transform.seq_x_y(x,y) -assert((x,y) == transform.seq_x_y(x,y)) - - -# test bbox transforms; transform the unit coordinate system to -# "display coords" -bboxin = unit_bbox() -ll = Point( Value(10), Value(10) ) -ur = Point( Value(200), Value(40) ) -bboxout = Bbox(ll, ur) - -transform = get_bbox_transform(bboxin, bboxout) - -assert( transform.xy_tup( (0,0) )==(10, 10)) -assert( transform.xy_tup( (1,1) )==(200, 40)) -assert( transform.xy_tup( (0.5, 0.5) )==(105, 25)) - -# simulate a resize -ur.x().set(400) -ur.y().set(400) -assert( transform.xy_tup( (0,0) )==(10, 10)) -assert( transform.xy_tup( (1,1) )==(400, 400)) -assert( transform.xy_tup( (0.5, 0.5) )==(205, 205)) - -pairs = ( ( (0, 0 ), (10, 10 ) ), - ( (1, 1 ), (400, 400) ), - ( (0.5, 0.5), (205, 205) ) ) - -for p1, p2 in pairs: - assert( closeto_seq( transform.xy_tup(p1), p2 ) ) - assert( closeto_seq( transform.inverse_xy_tup(p2), p1) ) - -# make some random bbox transforms and test inversion -def rand_point(): - xy = rand(2) - return Point( Value(xy[0]), Value(xy[1]) ) - -def rand_bbox(): - ll = rand_point() - ur = rand_point() - return Bbox(ll, ur) - -def rand_transform(): - b1 = rand_bbox() - b2 = rand_bbox() - return get_bbox_transform(b1, b2) - - -transform = rand_transform() -transform.set_funcx(Func(LOG10)) - -x = rand(100) -y = rand(100) -xys = zip(x,y) -for xy in xys: - xyt = transform.xy_tup(xy) - xyi = transform.inverse_xy_tup(xyt) - assert( closeto_seq(xy,xyi) ) - - -ll = Point( Value(-10), Value(-10) ) -ur = Point( Value(200), Value(40) ) -bbox = Bbox(ll, ur) -assert(bbox.xmin()==-10) -assert(bbox.xmax()==200) -assert(bbox.ymin()==-10) -assert(bbox.ymax()==40) - -bbox.update(xys, False) # don't ignore current lim - -bbox.update(xys, True) #ignore current lim -assert(bbox.xmin()==min(x)) -assert(bbox.xmax()==max(x)) -assert(bbox.ymin()==min(y)) -assert(bbox.ymax()==max(y)) - - -ll = Point( Value(-10), Value(-10) ) -ur = Point( Value(200), Value(40) ) -bbox = Bbox(ll, ur) - -ix = bbox.intervalx() -iy = bbox.intervaly() - -assert(bbox.xmin()==-10) -assert(bbox.xmax()==200) -assert(bbox.ymin()==-10) -assert(bbox.ymax()==40) - -ix.set_bounds(-30, 400) -assert(bbox.xmin()==-30) -assert(bbox.xmax()==400) -assert(bbox.ymin()==-10) -assert(bbox.ymax()==40) - - -num = Value(200.0) -den = Value(100.0) -div = num/den -assert(div.get()==2.0) - - -# test the inverse bbox functions -trans = rand_transform() -bbox1 = rand_bbox() -ibbox = inverse_transform_bbox(trans, bbox1) -bbox2 = transform_bbox(trans, ibbox) -assert(closeto_bbox(bbox1, bbox2)) - - -ll = Point( Value(-10), Value(-10) ) -ur = Point( Value(200), Value(40) ) -bbox = Bbox(ll, ur) -transform = get_bbox_transform(unit_bbox(), bbox) -assert( closeto_seq( inverse_transform_bbox(transform, bbox).get_bounds(), - (0,0,1,1))) -assert( closeto_seq( transform_bbox(transform, unit_bbox()).get_bounds(), - (-10,-10,210,50))) - - -# test the bbox all bounding functions -boxes = [rand_bbox() for i in range(20)] -xmin = min([box.xmin() for box in boxes]) -xmax = max([box.xmax() for box in boxes]) -ymin = min([box.ymin() for box in boxes]) -ymax = max([box.ymax() for box in boxes]) - -box = bbox_all(boxes) -assert( closeto_seq( box.get_bounds(), (xmin, ymin, xmax-xmin, ymax-ymin))) - - - - -t1 = rand_transform() -oboundsx = t1.get_bbox1().intervalx().get_bounds() -oboundsy = t1.get_bbox1().intervaly().get_bounds() -t2 = copy_bbox_transform(t1) -t1.get_bbox1().intervalx().set_bounds(1,2) -t2.get_bbox2().intervaly().set_bounds(-1,12) -newboundsx = t2.get_bbox1().intervalx().get_bounds() -newboundsy = t2.get_bbox1().intervaly().get_bounds() -assert(oboundsx==newboundsx) -assert(oboundsy==newboundsy) - - -import math -polar = FuncXY(POLAR) -assert( closeto_seq( polar.map(math.pi,1), (-1,0)) ) -assert( closeto_seq( polar.inverse(1,1), ( (math.pi/4), math.sqrt(2))) ) - - - -# This unit test requires "nan", which numarray.ieeespecial -# exports. (But we can keep using the numerix module.) -try: - from numarray.ieeespecial import nan - have_nan = True -except ImportError: - have_nan = False - -if have_nan: - y1=array([ 2,nan,1,2,3,4]) - y2=array([nan,nan,1,2,3,4]) - - x1=arange(len(y1)) - x2=arange(len(y2)) - - bbox1 = Bbox(Point(Value(0),Value(0)), - Point(Value(1),Value(1))) - - bbox2 = Bbox(Point(Value(0),Value(0)), - Point(Value(1),Value(1))) - - bbox1.update_numerix(x1,y1,1) - bbox2.update_numerix(x2,y2,1) - - assert( closeto_seq( bbox1.get_bounds(), bbox2.get_bounds() ) ) -else: - print 'nan could not be imported from numarray.ieeespecial, test skipped' - -print 'all tests passed' This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5857 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5857&view=rev Author: jdh2358 Date: 2008年07月24日 22:41:52 +0000 (2008年7月24日) Log Message: ----------- added simple gtk animation example Added Paths: ----------- trunk/matplotlib/examples/animation/simple_anim_gtk.py Added: trunk/matplotlib/examples/animation/simple_anim_gtk.py =================================================================== --- trunk/matplotlib/examples/animation/simple_anim_gtk.py (rev 0) +++ trunk/matplotlib/examples/animation/simple_anim_gtk.py 2008年07月24日 22:41:52 UTC (rev 5857) @@ -0,0 +1,30 @@ +""" +A simple example of an animated plot using a gtk backends +""" +import time +import numpy as np +import matplotlib +matplotlib.use('GTKAgg') # do this before importing pylab + +import matplotlib.pyplot as plt + +fig = plt.figure() + +ax = fig.add_subplot(111) + +def animate(): + tstart = time.time() # for profiling + x = np.arange(0, 2*np.pi, 0.01) # x-array + line, = ax.plot(x, np.sin(x)) + + for i in np.arange(1,200): + line.set_ydata(np.sin(x+i/10.0)) # update the data + fig.canvas.draw() # redraw the canvas + print 'FPS:' , 200/(time.time()-tstart) + raise SystemExit + +import gobject +print 'adding idle' +gobject.idle_add(animate) +print 'showing' +plt.show() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5856 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5856&view=rev Author: efiring Date: 2008年07月24日 22:37:03 +0000 (2008年7月24日) Log Message: ----------- Deleted obsolete memleak_transforms.py Removed Paths: ------------- trunk/matplotlib/unit/memleak_transforms.py Deleted: trunk/matplotlib/unit/memleak_transforms.py =================================================================== --- trunk/matplotlib/unit/memleak_transforms.py 2008年07月24日 22:35:06 UTC (rev 5855) +++ trunk/matplotlib/unit/memleak_transforms.py 2008年07月24日 22:37:03 UTC (rev 5856) @@ -1,73 +0,0 @@ -import os, sys, time, gc - -from matplotlib.numerix import array, asarray, alltrue -from matplotlib.numerix.mlab import rand -from matplotlib.transforms import Point, Bbox, Value, Affine -from matplotlib.transforms import multiply_affines -from matplotlib.transforms import Func, IDENTITY, LOG10, POLAR, FuncXY -from matplotlib.transforms import SeparableTransformation -from matplotlib.transforms import identity_transform, unit_bbox -from matplotlib.transforms import get_bbox_transform -from matplotlib.transforms import transform_bbox, inverse_transform_bbox -from matplotlib.transforms import bbox_all -from matplotlib.transforms import copy_bbox_transform, blend_xy_sep_transform - - -def report_memory(i): - pid = os.getpid() - if sys.platform=='sunos5': - command = 'ps -p %d -o rss,osz' % pid - else: - 'ps -p %d -o rss,sz' % pid - a2 = os.popen(command).readlines() - print i, ' ', a2[1], - return int(a2[1].split()[1]) - - - -# make some random bbox transforms and test inversion -def rand_point(): - xy = rand(2) - return Point( Value(xy[0]), Value(xy[1]) ) - -def rand_bbox(): - ll = rand_point() - ur = rand_point() - return Bbox(ll, ur) - -def rand_transform(): - b1 = rand_bbox() - b2 = rand_bbox() - return get_bbox_transform(b1, b2) - - - -class Line: - def __init__(self): - self._transform = identity_transform() - - def set_transform(self, t): - self._transform = t - -x, y = rand(2,10000) -indStart, indEnd = 30, 350 -for i in range(indEnd): - for j in range(20): - l = Line() - t1 = rand_transform() - t2 = rand_transform() - trans = blend_xy_sep_transform( t1, t2) - l.set_transform(trans) - xt, yt = trans.numerix_x_y(x, y) - xytup = tuple(rand(2)) - txytup = trans.xy_tup(xytup) - ixytup = trans.inverse_xy_tup(xytup) - seqt = trans.seq_xy_tups(zip(x,y)) - gc.collect() - val = report_memory(i) - if i==indStart: start = val # wait a few cycles for memory usage to stabilize - - -end = val -print 'Average memory consumed per loop: %1.4fk bytes\n' % ((end-start)/float(indEnd-indStart)) - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5855 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5855&view=rev Author: jdh2358 Date: 2008年07月24日 22:35:06 +0000 (2008年7月24日) Log Message: ----------- renamed anim to reflect tk Added Paths: ----------- trunk/matplotlib/examples/animation/simple_anim_tkagg.py Removed Paths: ------------- trunk/matplotlib/examples/animation/anim.py Deleted: trunk/matplotlib/examples/animation/anim.py =================================================================== --- trunk/matplotlib/examples/animation/anim.py 2008年07月24日 22:34:32 UTC (rev 5854) +++ trunk/matplotlib/examples/animation/anim.py 2008年07月24日 22:35:06 UTC (rev 5855) @@ -1,24 +0,0 @@ -#!/usr/bin/env python -""" -A simple example of an animated plot in tkagg -""" -import matplotlib -matplotlib.use('TkAgg') # do this before importing pylab - -import matplotlib.pyplot as plt -fig = plt.figure() -ax = fig.add_subplot(111) - -def animate(): - tstart = time.time() # for profiling - x = np.arange(0, 2*np.pi, 0.01) # x-array - line, = ax.plot(x, np.sin(x)) - - for i in np.arange(1,200): - line.set_ydata(np.sin(x+i/10.0)) # update the data - fig.canvas.draw() # redraw the canvas - print 'FPS:' , 200/(time.time()-tstart) - -win = fig.canvas.manager.window -fig.canvas.manager.window.after(100, animate) -plt.show() Copied: trunk/matplotlib/examples/animation/simple_anim_tkagg.py (from rev 5854, trunk/matplotlib/examples/animation/anim.py) =================================================================== --- trunk/matplotlib/examples/animation/simple_anim_tkagg.py (rev 0) +++ trunk/matplotlib/examples/animation/simple_anim_tkagg.py 2008年07月24日 22:35:06 UTC (rev 5855) @@ -0,0 +1,24 @@ +#!/usr/bin/env python +""" +A simple example of an animated plot in tkagg +""" +import matplotlib +matplotlib.use('TkAgg') # do this before importing pylab + +import matplotlib.pyplot as plt +fig = plt.figure() +ax = fig.add_subplot(111) + +def animate(): + tstart = time.time() # for profiling + x = np.arange(0, 2*np.pi, 0.01) # x-array + line, = ax.plot(x, np.sin(x)) + + for i in np.arange(1,200): + line.set_ydata(np.sin(x+i/10.0)) # update the data + fig.canvas.draw() # redraw the canvas + print 'FPS:' , 200/(time.time()-tstart) + +win = fig.canvas.manager.window +fig.canvas.manager.window.after(100, animate) +plt.show() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5854 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5854&view=rev Author: jdh2358 Date: 2008年07月24日 22:34:32 +0000 (2008年7月24日) Log Message: ----------- fixed anim.py to use tk idiom Modified Paths: -------------- trunk/matplotlib/examples/animation/anim.py Modified: trunk/matplotlib/examples/animation/anim.py =================================================================== --- trunk/matplotlib/examples/animation/anim.py 2008年07月24日 22:29:57 UTC (rev 5853) +++ trunk/matplotlib/examples/animation/anim.py 2008年07月24日 22:34:32 UTC (rev 5854) @@ -1,32 +1,24 @@ #!/usr/bin/env python """ -A simple example of an animated plot in matplotlib. You can test the -speed of animation of various backends by running the script with the -'-dSomeBackend' flag - -SC Aug 31 2005 mpl 0.83.2: -Here are some numbers from my system, where FPS is the frames rendered -per second - - GTK 29 FPS - GTKAgg 18 FPS - GTKCairo 15 FPS - TkAgg 13 FPS - QkAgg 13 FPS +A simple example of an animated plot in tkagg """ -import time +import matplotlib +matplotlib.use('TkAgg') # do this before importing pylab -import pylab as p +import matplotlib.pyplot as plt +fig = plt.figure() +ax = fig.add_subplot(111) -# turn interactive mode on for dynamic updates. If you aren't in -# interactive mode, you'll need to use a GUI event handler/timer. -p.ion() +def animate(): + tstart = time.time() # for profiling + x = np.arange(0, 2*np.pi, 0.01) # x-array + line, = ax.plot(x, np.sin(x)) -tstart = time.time() # for profiling -x = p.arange(0, 2*p.pi, 0.01) # x-array -line, = p.plot(x, p.sin(x)) -for i in p.arange(1,200): - line.set_ydata(p.sin(x+i/10.0)) # update the data - p.draw() # redraw the canvas + for i in np.arange(1,200): + line.set_ydata(np.sin(x+i/10.0)) # update the data + fig.canvas.draw() # redraw the canvas + print 'FPS:' , 200/(time.time()-tstart) -print 'FPS:' , 200/(time.time()-tstart) +win = fig.canvas.manager.window +fig.canvas.manager.window.after(100, animate) +plt.show() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5853 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5853&view=rev Author: pkienzle Date: 2008年07月24日 22:29:57 +0000 (2008年7月24日) Log Message: ----------- support mouse wheel in wx Modified Paths: -------------- trunk/matplotlib/examples/pylab_examples/image_slices_viewer.py trunk/matplotlib/lib/matplotlib/backend_bases.py trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py trunk/matplotlib/lib/matplotlib/backends/backend_wx.py Modified: trunk/matplotlib/examples/pylab_examples/image_slices_viewer.py =================================================================== --- trunk/matplotlib/examples/pylab_examples/image_slices_viewer.py 2008年07月24日 21:56:57 UTC (rev 5852) +++ trunk/matplotlib/examples/pylab_examples/image_slices_viewer.py 2008年07月24日 22:29:57 UTC (rev 5853) @@ -17,7 +17,7 @@ self.update() def onscroll(self, event): - print event.button + print event.button, event.step if event.button=='up': self.ind = numpy.clip(self.ind+1, 0, self.slices-1) else: Modified: trunk/matplotlib/lib/matplotlib/backend_bases.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backend_bases.py 2008年07月24日 21:56:57 UTC (rev 5852) +++ trunk/matplotlib/lib/matplotlib/backend_bases.py 2008年07月24日 22:29:57 UTC (rev 5853) @@ -768,7 +768,10 @@ *key* the key pressed: None, chr(range(255), 'shift', 'win', or 'control' + *step* + number of scroll steps (positive for 'up', negative for 'down') + Example usage:: def on_press(event): @@ -783,16 +786,18 @@ inaxes = None # the Axes instance if mouse us over axes xdata = None # x coord of mouse in data coords ydata = None # y coord of mouse in data coords + step = None # scroll steps for scroll events def __init__(self, name, canvas, x, y, button=None, key=None, - guiEvent=None): + step=0, guiEvent=None): """ x, y in figure coords, 0,0 = bottom, left - button pressed None, 1, 2, 3 + button pressed None, 1, 2, 3, 'up', 'down' """ LocationEvent.__init__(self, name, canvas, x, y, guiEvent=guiEvent) self.button = button self.key = key + self.step = step class PickEvent(Event): """ @@ -1050,7 +1055,7 @@ event = PickEvent(s, self, mouseevent, artist, **kwargs) self.callbacks.process(s, event) - def scroll_event(self, x, y, button, guiEvent=None): + def scroll_event(self, x, y, step, guiEvent=None): """ Backend derived classes should call this function on any scroll wheel event. x,y are the canvas coords: 0,0 is lower, @@ -1059,9 +1064,13 @@ This method will be call all functions connected to the 'scroll_event' with a :class:`MouseEvent` instance. """ - self._button = button + if step >= 0: + self._button = 'up' + else: + self._button = 'down' s = 'scroll_event' - mouseevent = MouseEvent(s, self, x, y, button, self._key, guiEvent=guiEvent) + mouseevent = MouseEvent(s, self, x, y, self._button, self._key, + step=step, guiEvent=guiEvent) self.callbacks.process(s, mouseevent) Modified: trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py 2008年07月24日 21:56:57 UTC (rev 5852) +++ trunk/matplotlib/lib/matplotlib/backends/backend_gtk.py 2008年07月24日 22:29:57 UTC (rev 5853) @@ -181,10 +181,10 @@ # flipy so y=0 is bottom of canvas y = self.allocation.height - event.y if event.direction==gdk.SCROLL_UP: - direction = 'up' + step = 1 else: - direction = 'down' - FigureCanvasBase.scroll_event(self, x, y, direction) + step = -1 + FigureCanvasBase.scroll_event(self, x, y, step) return False # finish event propagation? def button_press_event(self, widget, event): Modified: trunk/matplotlib/lib/matplotlib/backends/backend_wx.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_wx.py 2008年07月24日 21:56:57 UTC (rev 5852) +++ trunk/matplotlib/lib/matplotlib/backends/backend_wx.py 2008年07月24日 22:29:57 UTC (rev 5853) @@ -1160,9 +1160,36 @@ FigureCanvasBase.button_release_event(self, x, y, 1, guiEvent=evt) def _onMouseWheel(self, evt): - # TODO: implement mouse wheel handler - pass + """Translate mouse wheel events into matplotlib events""" + # Determine mouse location + x = evt.GetX() + y = self.figure.bbox.height - evt.GetY() + + # Convert delta/rotation/rate into a floating point step size + delta = evt.GetWheelDelta() + rotation = evt.GetWheelRotation() + rate = evt.GetLinesPerAction() + #print "delta,rotation,rate",delta,rotation,rate + step = rate*float(rotation)/delta + + # Done handling event + evt.Skip() + + # Mac is giving two events for every wheel event + # Need to skip every second one + if wx.Platform == '__WXMAC__': + if not hasattr(self,'_skipwheelevent'): + self._skipwheelevent = True + elif self._skipwheelevent: + self._skipwheelevent = False + return # Return without processing event + else: + self._skipwheelevent = True + + # Convert to mpl event + FigureCanvasBase.scroll_event(self, x, y, step, guiEvent=evt) + def _onMotion(self, evt): """Start measuring on an axis.""" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5852 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5852&view=rev Author: sameerd Date: 2008年07月24日 21:56:57 +0000 (2008年7月24日) Log Message: ----------- Fixing edge cases in rec_join in branch Modified Paths: -------------- branches/v0_91_maint/lib/matplotlib/mlab.py Modified: branches/v0_91_maint/lib/matplotlib/mlab.py =================================================================== --- branches/v0_91_maint/lib/matplotlib/mlab.py 2008年07月24日 21:56:08 UTC (rev 5851) +++ branches/v0_91_maint/lib/matplotlib/mlab.py 2008年07月24日 21:56:57 UTC (rev 5852) @@ -1951,10 +1951,12 @@ def rec_join(key, r1, r2, jointype='inner', defaults=None): """ join record arrays r1 and r2 on key; key is a tuple of field - names. if r1 and r2 have equal values on all the keys in the key + names. If r1 and r2 have equal values on all the keys in the key tuple, then their fields will be merged into a new record array - containing the intersection of the fields of r1 and r2 + containing the intersection of the fields of r1 and r2. + r1 (also r2) must not have any duplicate keys. + The jointype keyword can be 'inner', 'outer', 'leftouter'. To do a rightouter join just reverse r1 and r2. @@ -1993,9 +1995,6 @@ right_ind = np.array([r2d[k] for k in right_keys]) right_len = len(right_ind) - r2 = rec_drop_fields(r2, r1.dtype.names) - - def key_desc(name): 'if name is a string key, use the larger size of r1 or r2 before merging' dt1 = r1.dtype[name] @@ -2027,22 +2026,19 @@ newrec[k] = v for field in r1.dtype.names: - newrec[field][:common_len] = r1[field][r1ind] - if jointype == "outer" or jointype == "leftouter": + if common_len: + newrec[field][:common_len] = r1[field][r1ind] + if (jointype == "outer" or jointype == "leftouter") and left_len: newrec[field][common_len:(common_len+left_len)] = r1[field][left_ind] for field in r2.dtype.names: - newrec[field][:common_len] = r2[field][r2ind] - if jointype == "outer": - newrec[field][-right_len:] = r2[field][right_ind[right_ind.argsort()]] + if field not in key and common_len: + newrec[field][:common_len] = r2[field][r2ind] + if jointype == "outer" and right_len: + newrec[field][-right_len:] = r2[field][right_ind] - # sort newrec using the same order as r1 - sort_indices = r1ind.copy() - if jointype == "outer" or jointype == "leftouter": - sort_indices = np.append(sort_indices, left_ind) - newrec[:(common_len+left_len)] = newrec[sort_indices.argsort()] + newrec.sort(order=key) - return newrec.view(np.recarray) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5851 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5851&view=rev Author: sameerd Date: 2008年07月24日 21:56:08 +0000 (2008年7月24日) Log Message: ----------- Fixing edge cases in rec_join Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/mlab.py Modified: trunk/matplotlib/lib/matplotlib/mlab.py =================================================================== --- trunk/matplotlib/lib/matplotlib/mlab.py 2008年07月24日 21:56:06 UTC (rev 5850) +++ trunk/matplotlib/lib/matplotlib/mlab.py 2008年07月24日 21:56:08 UTC (rev 5851) @@ -2032,12 +2032,13 @@ newrec[k] = v for field in r1.dtype.names: - newrec[field][:common_len] = r1[field][r1ind] + if common_len: + newrec[field][:common_len] = r1[field][r1ind] if (jointype == "outer" or jointype == "leftouter") and left_len: newrec[field][common_len:(common_len+left_len)] = r1[field][left_ind] for field in r2.dtype.names: - if field not in key: + if field not in key and common_len: newrec[field][:common_len] = r2[field][r2ind] if jointype == "outer" and right_len: newrec[field][-right_len:] = r2[field][right_ind] This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5850 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5850&view=rev Author: jdh2358 Date: 2008年07月24日 21:56:06 +0000 (2008年7月24日) Log Message: ----------- minor cleanup of units example, added some to backend driver, more to be fixed Modified Paths: -------------- trunk/matplotlib/examples/tests/backend_driver.py trunk/matplotlib/examples/units/artist_tests.py trunk/matplotlib/examples/units/bar_demo2.py trunk/matplotlib/examples/units/bar_unit_demo.py trunk/matplotlib/examples/units/basic_units.py trunk/matplotlib/examples/units/evans_test.py trunk/matplotlib/examples/units/evans_test2.py trunk/matplotlib/examples/units/radian_demo.py trunk/matplotlib/examples/units/units_scatter.py trunk/matplotlib/unit/memleak_hawaii3.py Modified: trunk/matplotlib/examples/tests/backend_driver.py =================================================================== --- trunk/matplotlib/examples/tests/backend_driver.py 2008年07月24日 21:23:04 UTC (rev 5849) +++ trunk/matplotlib/examples/tests/backend_driver.py 2008年07月24日 21:56:06 UTC (rev 5850) @@ -121,9 +121,23 @@ 'color_cycle.py', ] +units_dir = os.path.join('..', 'units') +units_files = [ + 'annotate_with_units.py', + #'artist_tests.py', # broken, fixme + 'bar_demo2.py', + #'bar_unit_demo.py', # broken, fixme + #'ellipse_with_units.py', # broken, fixme + 'radian_demo.py', + 'units_sample.py', + #'units_scatter.py', # broken, fixme + ] + files = [os.path.join(pylab_dir, fname) for fname in pylab_files] +\ - [os.path.join(api_dir, fname) for fname in api_files] + [os.path.join(api_dir, fname) for fname in api_files] +\ + [os.path.join(units_dir, fname) for fname in units_files] + # tests known to fail on a given backend Modified: trunk/matplotlib/examples/units/artist_tests.py =================================================================== --- trunk/matplotlib/examples/units/artist_tests.py 2008年07月24日 21:23:04 UTC (rev 5849) +++ trunk/matplotlib/examples/units/artist_tests.py 2008年07月24日 21:56:06 UTC (rev 5850) @@ -14,9 +14,9 @@ import matplotlib.units as units from basic_units import cm, inch +import numpy as np +from pylab import figure, show -from pylab import figure, show, nx - fig = figure() ax = fig.add_subplot(111) ax.xaxis.set_units(cm) @@ -26,7 +26,7 @@ verts = [] for i in range(10): # a random line segment in inches - verts.append(zip(*inch*10*nx.mlab.rand(2, random.randint(2,15)))) + verts.append(zip(*inch*10*np.random.rand(2, random.randint(2,15)))) lc = collections.LineCollection(verts, axes=ax) ax.add_collection(lc) Modified: trunk/matplotlib/examples/units/bar_demo2.py =================================================================== --- trunk/matplotlib/examples/units/bar_demo2.py 2008年07月24日 21:23:04 UTC (rev 5849) +++ trunk/matplotlib/examples/units/bar_demo2.py 2008年07月24日 21:56:06 UTC (rev 5850) @@ -7,10 +7,11 @@ units) """ +import numpy as np from basic_units import cm, inch -from pylab import figure, show, nx +from pylab import figure, show -cms = cm *nx.arange(0, 10, 2) +cms = cm *np.arange(0, 10, 2) bottom=0*cm width=0.8*cm Modified: trunk/matplotlib/examples/units/bar_unit_demo.py =================================================================== --- trunk/matplotlib/examples/units/bar_unit_demo.py 2008年07月24日 21:23:04 UTC (rev 5849) +++ trunk/matplotlib/examples/units/bar_unit_demo.py 2008年07月24日 21:56:06 UTC (rev 5850) @@ -1,6 +1,7 @@ #!/usr/bin/env python +import numpy as np from basic_units import cm, inch -from pylab import figure, show,nx +from pylab import figure, show N = 5 menMeans = (150*cm, 160*cm, 146*cm, 172*cm, 155*cm) @@ -9,7 +10,7 @@ fig = figure() ax = fig.add_subplot(111) -ind = nx.arange(N) # the x locations for the groups +ind = np.arange(N) # the x locations for the groups width = 0.35 # the width of the bars p1 = ax.bar(ind, menMeans, width, color='r', bottom=0*cm, yerr=menStd) Modified: trunk/matplotlib/examples/units/basic_units.py =================================================================== --- trunk/matplotlib/examples/units/basic_units.py 2008年07月24日 21:23:04 UTC (rev 5849) +++ trunk/matplotlib/examples/units/basic_units.py 2008年07月24日 21:56:06 UTC (rev 5850) @@ -1,9 +1,8 @@ import math +import numpy as np - import matplotlib.units as units import matplotlib.ticker as ticker -import matplotlib.numerix as nx from matplotlib.axes import Axes from matplotlib.cbook import iterable @@ -122,7 +121,7 @@ self.proxy_target = self.value def get_compressed_copy(self, mask): - compressed_value = nx.ma.masked_array(self.value, mask=mask).compressed() + compressed_value = np.ma.masked_array(self.value, mask=mask).compressed() return TaggedValue(compressed_value, self.unit) def __getattribute__(self, name): @@ -135,9 +134,9 @@ def __array__(self, t = None, context = None): if t is not None: - return nx.asarray(self.value).astype(t) + return np.asarray(self.value).astype(t) else: - return nx.asarray(self.value, 'O') + return np.asarray(self.value, 'O') def __array_wrap__(self, array, context): return TaggedValue(array, self.unit) @@ -159,7 +158,7 @@ return IteratorProxy(iter(self.value), self.unit) def get_compressed_copy(self, mask): - new_value = nx.ma.masked_array(self.value, mask=mask).compressed() + new_value = np.ma.masked_array(self.value, mask=mask).compressed() return TaggedValue(new_value, self.unit) def convert_to(self, unit): @@ -211,7 +210,7 @@ return TaggedValue(array, self) def __array__(self, t=None, context=None): - ret = nx.array([1]) + ret = np.array([1]) if t is not None: return ret.astype(t) else: @@ -275,8 +274,8 @@ radians = BasicUnit('rad', 'radians') degrees = BasicUnit('deg', 'degrees') -radians.add_conversion_factor(degrees, 180.0/nx.pi) -degrees.add_conversion_factor(radians, nx.pi/180.0) +radians.add_conversion_factor(degrees, 180.0/np.pi) +degrees.add_conversion_factor(radians, np.pi/180.0) secs = BasicUnit('s', 'seconds') hertz = BasicUnit('Hz', 'Hertz') @@ -287,7 +286,7 @@ # radians formatting def rad_fn(x,pos=None): - n = int((x / nx.pi) * 2.0 + 0.25) + n = int((x / np.pi) * 2.0 + 0.25) if n == 0: return '0' elif n == 1: @@ -307,7 +306,7 @@ if unit==radians: return units.AxisInfo( - majloc=ticker.MultipleLocator(base=nx.pi/2), + majloc=ticker.MultipleLocator(base=np.pi/2), majfmt=ticker.FuncFormatter(rad_fn), label=unit.fullname, ) Modified: trunk/matplotlib/examples/units/evans_test.py =================================================================== --- trunk/matplotlib/examples/units/evans_test.py 2008年07月24日 21:23:04 UTC (rev 5849) +++ trunk/matplotlib/examples/units/evans_test.py 2008年07月24日 21:56:06 UTC (rev 5850) @@ -11,7 +11,7 @@ from matplotlib.cbook import iterable import matplotlib.units as units import matplotlib.ticker as ticker -from pylab import figure, show, nx +from pylab import figure, show class Foo: def __init__( self, val, unit=1.0 ): Modified: trunk/matplotlib/examples/units/evans_test2.py =================================================================== --- trunk/matplotlib/examples/units/evans_test2.py 2008年07月24日 21:23:04 UTC (rev 5849) +++ trunk/matplotlib/examples/units/evans_test2.py 2008年07月24日 21:56:06 UTC (rev 5850) @@ -3,13 +3,14 @@ This example shows how the unit class can determine the tick locating, formatting and axis labeling. """ +import numpy as np from basic_units import radians, degrees, cos -from pylab import figure, show, nx +from pylab import figure, show from matplotlib.cbook import iterable import math -x = nx.arange(0, 15, 0.01) * radians +x = np.arange(0, 15, 0.01) * radians fig = figure() Modified: trunk/matplotlib/examples/units/radian_demo.py =================================================================== --- trunk/matplotlib/examples/units/radian_demo.py 2008年07月24日 21:23:04 UTC (rev 5849) +++ trunk/matplotlib/examples/units/radian_demo.py 2008年07月24日 21:56:06 UTC (rev 5850) @@ -1,7 +1,8 @@ +import numpy as np from basic_units import radians, degrees, cos -from pylab import figure, show, nx +from pylab import figure, show -x = nx.arange(0, 15, 0.01) * radians +x = np.arange(0, 15, 0.01) * radians fig = figure() fig.subplots_adjust(hspace=0.3) Modified: trunk/matplotlib/examples/units/units_scatter.py =================================================================== --- trunk/matplotlib/examples/units/units_scatter.py 2008年07月24日 21:23:04 UTC (rev 5849) +++ trunk/matplotlib/examples/units/units_scatter.py 2008年07月24日 21:56:06 UTC (rev 5850) @@ -8,14 +8,16 @@ The example below shows support for unit conversions over masked arrays. """ +import numpy as np from basic_units import secs, hertz, minutes -from matplotlib.pylab import figure, show, nx +from matplotlib.pylab import figure, show # create masked array -xsecs = secs*nx.ma.MaskedArray((1,2,3,4,5,6,7,8), nx.Float, mask=(1,0,1,0,0,0,1,0)) -#xsecs = secs*nx.arange(1,10.) +xsecs = secs*np.ma.MaskedArray((1,2,3,4,5,6,7,8), (1,0,1,0,0,0,1,0), np.float) +#xsecs = secs*np.arange(1,10.) + fig = figure() ax1 = fig.add_subplot(3,1,1) ax1.scatter(xsecs, xsecs) Modified: trunk/matplotlib/unit/memleak_hawaii3.py =================================================================== --- trunk/matplotlib/unit/memleak_hawaii3.py 2008年07月24日 21:23:04 UTC (rev 5849) +++ trunk/matplotlib/unit/memleak_hawaii3.py 2008年07月24日 21:56:06 UTC (rev 5850) @@ -2,7 +2,7 @@ import os, sys, time, gc import matplotlib -matplotlib.use('PDF') +matplotlib.use('Agg') from matplotlib.cbook import report_memory import numpy as np This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5849 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5849&view=rev Author: jdh2358 Date: 2008年07月24日 21:23:04 +0000 (2008年7月24日) Log Message: ----------- fixed memleak hawaii rand Modified Paths: -------------- trunk/matplotlib/unit/memleak_hawaii3.py Modified: trunk/matplotlib/unit/memleak_hawaii3.py =================================================================== --- trunk/matplotlib/unit/memleak_hawaii3.py 2008年07月24日 20:06:36 UTC (rev 5848) +++ trunk/matplotlib/unit/memleak_hawaii3.py 2008年07月24日 21:23:04 UTC (rev 5849) @@ -10,7 +10,7 @@ # take a memory snapshot on indStart and compare it with indEnd -rand = np.mlab.rand +rand = np.random.rand indStart, indEnd = 200, 401 for i in range(indEnd): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5848 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5848&view=rev Author: pkienzle Date: 2008年07月24日 20:06:36 +0000 (2008年7月24日) Log Message: ----------- dynamic_collection: collection now has private copy of array Modified Paths: -------------- trunk/matplotlib/examples/animation/dynamic_collection.py Modified: trunk/matplotlib/examples/animation/dynamic_collection.py =================================================================== --- trunk/matplotlib/examples/animation/dynamic_collection.py 2008年07月24日 19:36:34 UTC (rev 5847) +++ trunk/matplotlib/examples/animation/dynamic_collection.py 2008年07月24日 20:06:36 UTC (rev 5848) @@ -34,6 +34,8 @@ color = cm.jet(rand()) offsets.append((x,y)) facecolors.append(color) + collection.set_offsets(offsets) + collection.set_facecolors(facecolors) fig.canvas.draw() elif event.key=='d': N = len(offsets) @@ -41,6 +43,8 @@ ind = random.randint(0,N-1) offsets.pop(ind) facecolors.pop(ind) + collection.set_offsets(offsets) + collection.set_facecolors(facecolors) fig.canvas.draw() fig.canvas.mpl_connect('key_press_event', onpress) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5847 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5847&view=rev Author: pkienzle Date: 2008年07月24日 19:36:34 +0000 (2008年7月24日) Log Message: ----------- nx is no longer a pylab symbol Modified Paths: -------------- trunk/matplotlib/examples/widgets/multicursor.py Modified: trunk/matplotlib/examples/widgets/multicursor.py =================================================================== --- trunk/matplotlib/examples/widgets/multicursor.py 2008年07月24日 19:27:11 UTC (rev 5846) +++ trunk/matplotlib/examples/widgets/multicursor.py 2008年07月24日 19:36:34 UTC (rev 5847) @@ -1,9 +1,9 @@ from matplotlib.widgets import MultiCursor -from pylab import figure, show, nx +from pylab import figure, show, pi, arange, sin -t = nx.arange(0.0, 2.0, 0.01) -s1 = nx.sin(2*nx.pi*t) -s2 = nx.sin(4*nx.pi*t) +t = arange(0.0, 2.0, 0.01) +s1 = sin(2*pi*t) +s2 = sin(4*pi*t) fig = figure() ax1 = fig.add_subplot(211) ax1.plot(t, s1) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5846 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5846&view=rev Author: jdh2358 Date: 2008年07月24日 19:27:11 +0000 (2008年7月24日) Log Message: ----------- Merged revisions 5845 via svnmerge from https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/branches/v0_91_maint ........ r5845 | jdh2358 | 2008年07月24日 14:24:18 -0500 (2008年7月24日) | 1 line bumped version num ........ Property Changed: ---------------- trunk/matplotlib/ Property changes on: trunk/matplotlib ___________________________________________________________________ Modified: svnmerge-integrated - /branches/v0_91_maint:1-5843 + /branches/v0_91_maint:1-5845 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5845 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5845&view=rev Author: jdh2358 Date: 2008年07月24日 19:24:18 +0000 (2008年7月24日) Log Message: ----------- bumped version num Modified Paths: -------------- branches/v0_91_maint/lib/matplotlib/__init__.py Modified: branches/v0_91_maint/lib/matplotlib/__init__.py =================================================================== --- branches/v0_91_maint/lib/matplotlib/__init__.py 2008年07月24日 18:39:12 UTC (rev 5844) +++ branches/v0_91_maint/lib/matplotlib/__init__.py 2008年07月24日 19:24:18 UTC (rev 5845) @@ -55,7 +55,7 @@ """ from __future__ import generators -__version__ = '0.91.4' +__version__ = '0.91.5' __revision__ = '$Revision$' __date__ = '$Date$' This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5844 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5844&view=rev Author: jdh2358 Date: 2008年07月24日 18:39:12 +0000 (2008年7月24日) Log Message: ----------- Merged revisions 5843 via svnmerge from https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/branches/v0_91_maint ........ r5843 | jdh2358 | 2008年07月24日 13:35:53 -0500 (2008年7月24日) | 1 line updated api changes and changelog to reflect mlab2 deprecation ........ Property Changed: ---------------- trunk/matplotlib/ Property changes on: trunk/matplotlib ___________________________________________________________________ Modified: svnmerge-integrated - /branches/v0_91_maint:1-5835 + /branches/v0_91_maint:1-5843 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5843 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5843&view=rev Author: jdh2358 Date: 2008年07月24日 18:35:53 +0000 (2008年7月24日) Log Message: ----------- updated api changes and changelog to reflect mlab2 deprecation Modified Paths: -------------- branches/v0_91_maint/CHANGELOG Modified: branches/v0_91_maint/CHANGELOG =================================================================== --- branches/v0_91_maint/CHANGELOG 2008年07月24日 18:35:24 UTC (rev 5842) +++ branches/v0_91_maint/CHANGELOG 2008年07月24日 18:35:53 UTC (rev 5843) @@ -1,3 +1,7 @@ +2008年07月24日 Deprecated (raise NotImplementedError) all the mlab2 + functions from matplotlib.mlab out of concern that some of + them were not clean room implementations. JDH + 2008年07月16日 Improve error handling in texmanager, thanks to Ian Henry for reporting - DSD This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 5842 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5842&view=rev Author: jdh2358 Date: 2008年07月24日 18:35:24 +0000 (2008年7月24日) Log Message: ----------- updated api changes and changelog to reflect mlab2 deprecation Modified Paths: -------------- trunk/matplotlib/API_CHANGES trunk/matplotlib/CHANGELOG Modified: trunk/matplotlib/API_CHANGES =================================================================== --- trunk/matplotlib/API_CHANGES 2008年07月24日 17:07:43 UTC (rev 5841) +++ trunk/matplotlib/API_CHANGES 2008年07月24日 18:35:24 UTC (rev 5842) @@ -1,6 +1,11 @@ + Changes for 0.98.x ================== +* Deprecated (raise NotImplementedError) all the mlab2 functions from + matplotlib.mlab out of concern that some of them were not clean room + implementations. + * Methods get_offsets and set_offsets added to Collections base class. Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2008年07月24日 17:07:43 UTC (rev 5841) +++ trunk/matplotlib/CHANGELOG 2008年07月24日 18:35:24 UTC (rev 5842) @@ -1,3 +1,7 @@ +2008年07月24日 Deprecated (raise NotImplementedError) all the mlab2 + functions from matplotlib.mlab out of concern that some of + them were not clean room implementations. JDH + 2008年07月24日 Rewrite of a significant portion of the clabel code (class ContourLabeler) to improve inlining. - DMK This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.