Revision: 6429
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6429&view=rev
Author:   jdh2358
Date:     2008-11-21 11:28:32 +0000 (Fri, 21 Nov 2008)

Log Message:
-----------
Merged revisions 6086,6365,6427-6428 via svnmerge from 
https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/branches/v0_91_maint

........
  r6086 | mdboom | 2008-09-11 15:28:11 -0500 (Thu, 11 Sep 2008) | 2 lines
  
  Fix backticks in PS output.
........
  r6365 | mdboom | 2008-11-05 09:15:28 -0600 (Wed, 05 Nov 2008) | 1 line
  
  Fix bug in zoom rectangle with twin axes
........
  r6427 | jdh2358 | 2008-11-21 05:14:12 -0600 (Fri, 21 Nov 2008) | 1 line
  
  fixed poly between
........
  r6428 | jdh2358 | 2008-11-21 05:15:04 -0600 (Fri, 21 Nov 2008) | 1 line
  
  fixed poly below
........

Modified Paths:
--------------
    trunk/matplotlib/CHANGELOG
    trunk/matplotlib/lib/matplotlib/backend_bases.py
    trunk/matplotlib/lib/matplotlib/mlab.py

Property Changed:
----------------
    trunk/matplotlib/


Property changes on: trunk/matplotlib
___________________________________________________________________
Modified: svnmerge-integrated
   - /branches/v0_91_maint:1-6073,6149
   + /branches/v0_91_maint:1-6428

Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG  2008-11-21 11:15:04 UTC (rev 6428)
+++ trunk/matplotlib/CHANGELOG  2008-11-21 11:28:32 UTC (rev 6429)
@@ -54,6 +54,10 @@
 
 2008-10-08 Add path simplification support to paths with gaps. - EF
 
+=======
+2008-11-05 Fix bug with zoom to rectangle and twin axes - MGD
+
+>>>>>>> .merge-right.r6428
 2008-10-05 Fix problem with AFM files that don't specify the font's
            full name or family name. - JKS
 
@@ -97,6 +101,10 @@
 2008-09-10 Add "filled" kwarg to Path.intersects_path and
            Path.intersects_bbox. - MGD
 
+=======
+2008-09-11 Fix use of backticks in PS - MGD
+
+>>>>>>> .merge-right.r6086
 2008-09-07 Changed full arrows slightly to avoid an xpdf rendering
            problem reported by Friedrich Hagedorn. - JKS
 

Modified: trunk/matplotlib/lib/matplotlib/backend_bases.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backend_bases.py    2008-11-21 11:15:04 UTC 
(rev 6428)
+++ trunk/matplotlib/lib/matplotlib/backend_bases.py    2008-11-21 11:28:32 UTC 
(rev 6429)
@@ -1883,6 +1883,8 @@
         for cur_xypress in self._xypress:
             x, y = event.x, event.y
             lastx, lasty, a, ind, lim, trans = cur_xypress
+            if a._sharex or a._sharey:
+                continue
             # ignore singular clicks - 5 pixels is a threshold
             if abs(x-lastx)<5 or abs(y-lasty)<5:
                 self._xypress = None

Modified: trunk/matplotlib/lib/matplotlib/mlab.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/mlab.py     2008-11-21 11:15:04 UTC (rev 
6428)
+++ trunk/matplotlib/lib/matplotlib/mlab.py     2008-11-21 11:28:32 UTC (rev 
6429)
@@ -1438,6 +1438,181 @@
     else: return X
 
 
+def slopes(x,y):
+    """
+    SLOPES calculate the slope y'(x) Given data vectors X and Y SLOPES
+    calculates Y'(X), i.e the slope of a curve Y(X). The slope is
+    estimated using the slope obtained from that of a parabola through
+    any three consecutive points.
+
+    This method should be superior to that described in the appendix
+    of A CONSISTENTLY WELL BEHAVED METHOD OF INTERPOLATION by Russel
+    W. Stineman (Creative Computing July 1980) in at least one aspect:
+
+    Circles for interpolation demand a known aspect ratio between x-
+    and y-values.  For many functions, however, the abscissa are given
+    in different dimensions, so an aspect ratio is completely
+    arbitrary.
+
+    The parabola method gives very similar results to the circle
+    method for most regular cases but behaves much better in special
+    cases
+
+    Norbert Nemec, Institute of Theoretical Physics, University or
+    Regensburg, April 2006 Norbert.Nemec at physik.uni-regensburg.de
+
+    (inspired by a original implementation by Halldor Bjornsson,
+    Icelandic Meteorological Office, March 2006 halldor at vedur.is)
+    """
+    # Cast key variables as float.
+    x=np.asarray(x, np.float_)
+    y=np.asarray(y, np.float_)
+
+    yp=np.zeros(y.shape, np.float_)
+
+    dx=x[1:] - x[:-1]
+    dy=y[1:] - y[:-1]
+    dydx = dy/dx
+    yp[1:-1] = (dydx[:-1] * dx[1:] + dydx[1:] * dx[:-1])/(dx[1:] + dx[:-1])
+    yp[0] = 2.0 * dy[0]/dx[0] - yp[1]
+    yp[-1] = 2.0 * dy[-1]/dx[-1] - yp[-2]
+    return yp
+
+
+def stineman_interp(xi,x,y,yp=None):
+    """
+    STINEMAN_INTERP Well behaved data interpolation.  Given data
+    vectors X and Y, the slope vector YP and a new abscissa vector XI
+    the function stineman_interp(xi,x,y,yp) uses Stineman
+    interpolation to calculate a vector YI corresponding to XI.
+
+    Here's an example that generates a coarse sine curve, then
+    interpolates over a finer abscissa:
+
+      x = linspace(0,2*pi,20);  y = sin(x); yp = cos(x)
+      xi = linspace(0,2*pi,40);
+      yi = stineman_interp(xi,x,y,yp);
+      plot(x,y,'o',xi,yi)
+
+    The interpolation method is described in the article A
+    CONSISTENTLY WELL BEHAVED METHOD OF INTERPOLATION by Russell
+    W. Stineman. The article appeared in the July 1980 issue of
+    Creative Computing with a note from the editor stating that while
+    they were
+
+      not an academic journal but once in a while something serious
+      and original comes in adding that this was
+      "apparently a real solution" to a well known problem.
+
+    For yp=None, the routine automatically determines the slopes using
+    the "slopes" routine.
+
+    X is assumed to be sorted in increasing order
+
+    For values xi[j] < x[0] or xi[j] > x[-1], the routine tries a
+    extrapolation.  The relevance of the data obtained from this, of
+    course, questionable...
+
+    original implementation by Halldor Bjornsson, Icelandic
+    Meteorolocial Office, March 2006 halldor at vedur.is
+
+    completely reworked and optimized for Python by Norbert Nemec,
+    Institute of Theoretical Physics, University or Regensburg, April
+    2006 Norbert.Nemec at physik.uni-regensburg.de
+
+    """
+
+    # Cast key variables as float.
+    x=np.asarray(x, np.float_)
+    y=np.asarray(y, np.float_)
+    assert x.shape == y.shape
+    N=len(y)
+
+    if yp is None:
+        yp = slopes(x,y)
+    else:
+        yp=np.asarray(yp, np.float_)
+
+    xi=np.asarray(xi, np.float_)
+    yi=np.zeros(xi.shape, np.float_)
+
+    # calculate linear slopes
+    dx = x[1:] - x[:-1]
+    dy = y[1:] - y[:-1]
+    s = dy/dx  #note length of s is N-1 so last element is #N-2
+
+    # find the segment each xi is in
+    # this line actually is the key to the efficiency of this implementation
+    idx = np.searchsorted(x[1:-1], xi)
+
+    # now we have generally: x[idx[j]] <= xi[j] <= x[idx[j]+1]
+    # except at the boundaries, where it may be that xi[j] < x[0] or xi[j] > 
x[-1]
+
+    # the y-values that would come out from a linear interpolation:
+    sidx = s.take(idx)
+    xidx = x.take(idx)
+    yidx = y.take(idx)
+    xidxp1 = x.take(idx+1)
+    yo = yidx + sidx * (xi - xidx)
+
+    # the difference that comes when using the slopes given in yp
+    dy1 = (yp.take(idx)- sidx) * (xi - xidx)       # using the yp slope of the 
left point
+    dy2 = (yp.take(idx+1)-sidx) * (xi - xidxp1) # using the yp slope of the 
right point
+
+    dy1dy2 = dy1*dy2
+    # The following is optimized for Python. The solution actually
+    # does more calculations than necessary but exploiting the power
+    # of numpy, this is far more efficient than coding a loop by hand
+    # in Python
+    yi = yo + dy1dy2 * np.choose(np.array(np.sign(dy1dy2), np.int32)+1,
+                                 ((2*xi-xidx-xidxp1)/((dy1-dy2)*(xidxp1-xidx)),
+                                  0.0,
+                                  1/(dy1+dy2),))
+    return yi
+
+def inside_poly(points, verts):
+    """
+    points is a sequence of x,y points
+    verts is a sequence of x,y vertices of a poygon
+
+    return value is a sequence of indices into points for the points
+    that are inside the polygon
+    """
+    res, =  np.nonzero(nxutils.points_inside_poly(points, verts))
+    return res
+
+def poly_below(ymin, xs, ys):
+    """
+    given a arrays *xs* and *ys*, return the vertices of a polygon
+    that has a scalar lower bound *ymin* and an upper bound at the *ys*.
+
+    intended for use with Axes.fill, eg::
+
+      xv, yv = poly_below(0, x, y)
+      ax.fill(xv, yv)
+    """
+    return poly_between(xs, ys, xmin)
+
+
+def poly_between(x, ylower, yupper):
+    """
+    given a sequence of x, ylower and yupper, return the polygon that
+    fills the regions between them.  ylower or yupper can be scalar or
+    iterable.  If they are iterable, they must be equal in length to x
+
+    return value is x, y arrays for use with Axes.fill
+    """
+    Nx = len(x)
+    if not cbook.iterable(ylower):
+        ylower = ylower*np.ones(Nx)
+
+    if not cbook.iterable(yupper):
+        yupper = yupper*np.ones(Nx)
+
+    x = np.concatenate( (x, x[::-1]) )
+    y = np.concatenate( (yupper, ylower[::-1]) )
+    return x,y
+
 ### the following code was written and submitted by Fernando Perez
 ### from the ipython numutils package under a BSD license
 # begin fperez functions


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins

Reply via email to