Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b2bf68e

Browse files
committed
Merged revisions 7475-7477,7480,7482 via svnmerge from
https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/branches/v0_99_maint ........ r7475 | jdh2358 | 2009-08-11 14:26:50 -1000 (Tue, 11 Aug 2009) | 1 line update the contributing faq ........ r7476 | jdh2358 | 2009-08-12 01:37:13 -1000 (Wed, 12 Aug 2009) | 1 line do case insensitive color string matching, as suggested in sf bug 2834598 ........ r7477 | efiring | 2009-08-12 06:53:41 -1000 (Wed, 12 Aug 2009) | 2 lines Typo in navigation_toolbar.rst. ........ r7480 | jdh2358 | 2009-08-12 14:41:58 -1000 (Wed, 12 Aug 2009) | 1 line add the pngs referenced by sphinx css; closes sf bug 2834121 ........ r7482 | efiring | 2009-08-13 14:24:40 -1000 (Thu, 13 Aug 2009) | 2 lines Remove older versions of some functions in mlab.py; closes bug 2806535 ........ svn path=/trunk/matplotlib/; revision=7483
2 parents 87a1ae3 + 33e86b8 commit b2bf68e

6 files changed

Lines changed: 30 additions & 180 deletions

File tree

doc/_static/contents.png

202 Bytes
Loading

doc/_static/navigation.png

218 Bytes
Loading

doc/faq/howto_faq.rst

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,31 @@ list.
516516

517517
If you have made lots of local changes and do not want to a diff
518518
against the entire tree, but rather against a single directory or
519-
file, that is fine, but we do prefer svn diffs against HEAD.
519+
file, that is fine, but we do prefer svn diffs against the top level
520+
(where setup.py lives) since it is nice to have a consistent way to
521+
apply them.
522+
523+
If you are posting a patch to fix a code bug, please explain your
524+
patch in words -- what was broken before and how you fixed it. Also,
525+
even if your patch is particularly simple, just a few lines or a
526+
single function replacement, we encourage people to submit svn diffs
527+
against HEAD or the branch they are patching. It just makes life
528+
simpler for us, since we (fortunately) get a lot of contributions, and
529+
want to receive them in a standard format. If possible, for any
530+
non-trivial change, please include a complete, free-standing example
531+
that the developers can run unmodified which shows the undesired
532+
behavior pre-patch and the desired behavior post-patch, with a clear
533+
verbal description of what to look for. The original developer may
534+
have written the function you are working on years ago, and may no
535+
longer be with the project, so it is quite possible you are the world
536+
expert on the code you are patching and we want to hear as much detail
537+
as you can offer.
538+
539+
When emailing your patch and examples, feel free to paste any code
540+
into the text of the message, indeed we encourage it, but also attach
541+
the patches and examples since many email clients screw up the
542+
formatting of plain text, and we spend lots of needless time trying to
543+
reformat the code to make it usable.
520544

521545
You should check out the guide to developing matplotlib to make sure
522546
your patch abides by our coding conventions

doc/users/navigation_toolbar.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ The ``Pan/Zoom`` button
3535
figure, dragging it to a new position. When you release it, the
3636
data under the point where you pressed will be moved to the point
3737
where you released. If you press 'x' or 'y' while panning the
38-
motion will be contrained to the x or y axis, respectively. Press
38+
motion will be constrained to the x or y axis, respectively. Press
3939
the right mouse button to zoom, dragging it to a new position.
4040
The x axis will be zoomed in proportionate to the rightward
4141
movement and zoomed out proportionate to the leftward movement.

lib/matplotlib/colors.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -282,13 +282,14 @@ def to_rgb(self, arg):
282282

283283
try:
284284
if cbook.is_string_like(arg):
285-
color = self.colors.get(arg, None)
285+
argl = arg.lower()
286+
color = self.colors.get(argl, None)
286287
if color is None:
287-
str1 = cnames.get(arg, arg)
288+
str1 = cnames.get(argl, argl)
288289
if str1.startswith('#'):
289290
color = hex2color(str1)
290291
else:
291-
fl = float(arg)
292+
fl = float(argl)
292293
if fl < 0 or fl > 1:
293294
raise ValueError(
294295
'gray (string) must be in range 0-1')

lib/matplotlib/mlab.py

Lines changed: 0 additions & 175 deletions
Original file line numberDiff line numberDiff line change
@@ -1304,181 +1304,6 @@ def splitfunc(x):
13041304
else: return X
13051305

13061306

1307-
def slopes(x,y):
1308-
"""
1309-
SLOPES calculate the slope y'(x) Given data vectors X and Y SLOPES
1310-
calculates Y'(X), i.e the slope of a curve Y(X). The slope is
1311-
estimated using the slope obtained from that of a parabola through
1312-
any three consecutive points.
1313-
1314-
This method should be superior to that described in the appendix
1315-
of A CONSISTENTLY WELL BEHAVED METHOD OF INTERPOLATION by Russel
1316-
W. Stineman (Creative Computing July 1980) in at least one aspect:
1317-
1318-
Circles for interpolation demand a known aspect ratio between x-
1319-
and y-values. For many functions, however, the abscissa are given
1320-
in different dimensions, so an aspect ratio is completely
1321-
arbitrary.
1322-
1323-
The parabola method gives very similar results to the circle
1324-
method for most regular cases but behaves much better in special
1325-
cases
1326-
1327-
Norbert Nemec, Institute of Theoretical Physics, University or
1328-
Regensburg, April 2006 Norbert.Nemec at physik.uni-regensburg.de
1329-
1330-
(inspired by a original implementation by Halldor Bjornsson,
1331-
Icelandic Meteorological Office, March 2006 halldor at vedur.is)
1332-
"""
1333-
# Cast key variables as float.
1334-
x=np.asarray(x, np.float_)
1335-
y=np.asarray(y, np.float_)
1336-
1337-
yp=np.zeros(y.shape, np.float_)
1338-
1339-
dx=x[1:] - x[:-1]
1340-
dy=y[1:] - y[:-1]
1341-
dydx = dy/dx
1342-
yp[1:-1] = (dydx[:-1] * dx[1:] + dydx[1:] * dx[:-1])/(dx[1:] + dx[:-1])
1343-
yp[0] = 2.0 * dy[0]/dx[0] - yp[1]
1344-
yp[-1] = 2.0 * dy[-1]/dx[-1] - yp[-2]
1345-
return yp
1346-
1347-
1348-
def stineman_interp(xi,x,y,yp=None):
1349-
"""
1350-
STINEMAN_INTERP Well behaved data interpolation. Given data
1351-
vectors X and Y, the slope vector YP and a new abscissa vector XI
1352-
the function stineman_interp(xi,x,y,yp) uses Stineman
1353-
interpolation to calculate a vector YI corresponding to XI.
1354-
1355-
Here's an example that generates a coarse sine curve, then
1356-
interpolates over a finer abscissa:
1357-
1358-
x = linspace(0,2*pi,20); y = sin(x); yp = cos(x)
1359-
xi = linspace(0,2*pi,40);
1360-
yi = stineman_interp(xi,x,y,yp);
1361-
plot(x,y,'o',xi,yi)
1362-
1363-
The interpolation method is described in the article A
1364-
CONSISTENTLY WELL BEHAVED METHOD OF INTERPOLATION by Russell
1365-
W. Stineman. The article appeared in the July 1980 issue of
1366-
Creative Computing with a note from the editor stating that while
1367-
they were
1368-
1369-
not an academic journal but once in a while something serious
1370-
and original comes in adding that this was
1371-
"apparently a real solution" to a well known problem.
1372-
1373-
For yp=None, the routine automatically determines the slopes using
1374-
the "slopes" routine.
1375-
1376-
X is assumed to be sorted in increasing order
1377-
1378-
For values xi[j] < x[0] or xi[j] > x[-1], the routine tries a
1379-
extrapolation. The relevance of the data obtained from this, of
1380-
course, questionable...
1381-
1382-
original implementation by Halldor Bjornsson, Icelandic
1383-
Meteorolocial Office, March 2006 halldor at vedur.is
1384-
1385-
completely reworked and optimized for Python by Norbert Nemec,
1386-
Institute of Theoretical Physics, University or Regensburg, April
1387-
2006 Norbert.Nemec at physik.uni-regensburg.de
1388-
1389-
"""
1390-
1391-
# Cast key variables as float.
1392-
x=np.asarray(x, np.float_)
1393-
y=np.asarray(y, np.float_)
1394-
assert x.shape == y.shape
1395-
N=len(y)
1396-
1397-
if yp is None:
1398-
yp = slopes(x,y)
1399-
else:
1400-
yp=np.asarray(yp, np.float_)
1401-
1402-
xi=np.asarray(xi, np.float_)
1403-
yi=np.zeros(xi.shape, np.float_)
1404-
1405-
# calculate linear slopes
1406-
dx = x[1:] - x[:-1]
1407-
dy = y[1:] - y[:-1]
1408-
s = dy/dx #note length of s is N-1 so last element is #N-2
1409-
1410-
# find the segment each xi is in
1411-
# this line actually is the key to the efficiency of this implementation
1412-
idx = np.searchsorted(x[1:-1], xi)
1413-
1414-
# now we have generally: x[idx[j]] <= xi[j] <= x[idx[j]+1]
1415-
# except at the boundaries, where it may be that xi[j] < x[0] or xi[j] > x[-1]
1416-
1417-
# the y-values that would come out from a linear interpolation:
1418-
sidx = s.take(idx)
1419-
xidx = x.take(idx)
1420-
yidx = y.take(idx)
1421-
xidxp1 = x.take(idx+1)
1422-
yo = yidx + sidx * (xi - xidx)
1423-
1424-
# the difference that comes when using the slopes given in yp
1425-
dy1 = (yp.take(idx)- sidx) * (xi - xidx) # using the yp slope of the left point
1426-
dy2 = (yp.take(idx+1)-sidx) * (xi - xidxp1) # using the yp slope of the right point
1427-
1428-
dy1dy2 = dy1*dy2
1429-
# The following is optimized for Python. The solution actually
1430-
# does more calculations than necessary but exploiting the power
1431-
# of numpy, this is far more efficient than coding a loop by hand
1432-
# in Python
1433-
yi = yo + dy1dy2 * np.choose(np.array(np.sign(dy1dy2), np.int32)+1,
1434-
((2*xi-xidx-xidxp1)/((dy1-dy2)*(xidxp1-xidx)),
1435-
0.0,
1436-
1/(dy1+dy2),))
1437-
return yi
1438-
1439-
def inside_poly(points, verts):
1440-
"""
1441-
points is a sequence of x,y points
1442-
verts is a sequence of x,y vertices of a poygon
1443-
1444-
return value is a sequence of indices into points for the points
1445-
that are inside the polygon
1446-
"""
1447-
res, = np.nonzero(nxutils.points_inside_poly(points, verts))
1448-
return res
1449-
1450-
def poly_below(ymin, xs, ys):
1451-
"""
1452-
given a arrays *xs* and *ys*, return the vertices of a polygon
1453-
that has a scalar lower bound *ymin* and an upper bound at the *ys*.
1454-
1455-
intended for use with Axes.fill, eg::
1456-
1457-
xv, yv = poly_below(0, x, y)
1458-
ax.fill(xv, yv)
1459-
"""
1460-
return poly_between(xs, ys, xmin)
1461-
1462-
1463-
def poly_between(x, ylower, yupper):
1464-
"""
1465-
given a sequence of x, ylower and yupper, return the polygon that
1466-
fills the regions between them. ylower or yupper can be scalar or
1467-
iterable. If they are iterable, they must be equal in length to x
1468-
1469-
return value is x, y arrays for use with Axes.fill
1470-
"""
1471-
Nx = len(x)
1472-
if not cbook.iterable(ylower):
1473-
ylower = ylower*np.ones(Nx)
1474-
1475-
if not cbook.iterable(yupper):
1476-
yupper = yupper*np.ones(Nx)
1477-
1478-
x = np.concatenate( (x, x[::-1]) )
1479-
y = np.concatenate( (yupper, ylower[::-1]) )
1480-
return x,y
1481-
14821307
### the following code was written and submitted by Fernando Perez
14831308
### from the ipython numutils package under a BSD license
14841309
# begin fperez functions

0 commit comments

Comments
 (0)