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
(4) |
2
|
3
(2) |
4
(3) |
5
(5) |
6
(1) |
7
(3) |
8
|
9
(3) |
10
(3) |
11
(6) |
12
(2) |
13
(4) |
14
(1) |
15
(2) |
16
(1) |
17
(6) |
18
(8) |
19
|
20
(1) |
21
|
22
|
23
(3) |
24
(2) |
25
(2) |
26
(1) |
27
(2) |
28
(7) |
29
(2) |
30
(4) |
|
|
|
|
Revision: 6138 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6138&view=rev Author: jswhit Date: 2008年09月30日 20:14:38 +0000 (2008年9月30日) Log Message: ----------- add van der Grinten ('vandg') Modified Paths: -------------- trunk/toolkits/basemap/Changelog trunk/toolkits/basemap/examples/test.py trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py trunk/toolkits/basemap/lib/mpl_toolkits/basemap/proj.py Modified: trunk/toolkits/basemap/Changelog =================================================================== --- trunk/toolkits/basemap/Changelog 2008年09月30日 20:07:54 UTC (rev 6137) +++ trunk/toolkits/basemap/Changelog 2008年09月30日 20:14:38 UTC (rev 6138) @@ -1,9 +1,8 @@ version 0.99.2 (not yet released) * Added McBryde-Thomas Flat Polar Quartic (projection = - 'mbtfpq') and Gall Stereographic Cylindrical (projection = - 'gall'). - * fix warpimage and bluemarble methods for projection = 'cyl', - 'robin', 'moll' and 'sinu'. + 'mbtfpq'), Gall Stereographic Cylindrical (projection = + 'gall') and van der Grinten (projection = 'vandg'). + * fix bugs in warpimage and bluemarble methods for several projections. * bugfix patch for rotate_vector from David Huard. David also contributed the beginnings of a test suite. * _geoslib.so now installed in mpl_toolkits.basemap. Modified: trunk/toolkits/basemap/examples/test.py =================================================================== --- trunk/toolkits/basemap/examples/test.py 2008年09月30日 20:07:54 UTC (rev 6137) +++ trunk/toolkits/basemap/examples/test.py 2008年09月30日 20:14:38 UTC (rev 6138) @@ -662,7 +662,42 @@ plt.title('McBryde-Thomas Flat Polar Quartic') print 'plotting McBryde-Thomas Flat Polar Quartic example ...' print m.proj4string + +# create new figure +fig=plt.figure() +# create Basemap instance for van der Grinten projection. +m = Basemap(projection='vandg',lon_0=0.5*(lonsin[0]+lonsin[-1])) +# add poles to data. +tmpdat = np.empty((len(latsin)+2,len(lonsin)),topodatin.dtype) +tmpdat[1:-1,:] = topodatin +tmpdat[0,:] = topodatin[1,:].mean() +tmpdat[-1,:] = topodatin[-1,:].mean() +lats2 = np.empty(len(latsin)+2,latsin.dtype) +lats2[1:-1] = latsin +lats2[0] = -90; latsin[-1] = 90 +ax = fig.add_axes([0.1,0.1,0.7,0.7]) +# plot image over map with pcolormesh. +x,y = m(*np.meshgrid(lonsin,lats2)) +p = m.pcolormesh(x,y,tmpdat,shading='flat') +pos = ax.get_position() +l, b, w, h = pos.bounds +cax = plt.axes([l+w+0.05, b, 0.05, h]) # setup colorbar axes. +plt.colorbar(cax=cax) # draw colorbar +plt.axes(ax) # make the original axes current again +# draw coastlines and political boundaries. +m.drawcoastlines() +# draw parallels and meridians +parallels = np.arange(-80.,90,20.) +m.drawparallels(parallels) +meridians = np.arange(0.,360.,60.) +m.drawmeridians(meridians) +# draw boundary around map region. +m.drawmapboundary() +# add a title. +plt.title('van der Grinten') +print 'plotting van der Grinten example ...' +print m.proj4string + plt.show() - print 'done' Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py =================================================================== --- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2008年09月30日 20:07:54 UTC (rev 6137) +++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2008年09月30日 20:14:38 UTC (rev 6138) @@ -69,7 +69,8 @@ 'sinu' : 'Sinusoidal', 'moll' : 'Mollweide', 'robin' : 'Robinson', - 'mbtfpq' : 'McBryde-Thomas Flat-Polar Quartic', + 'vandg' : 'van der Grinten', + 'mbtfpq' : 'McBryde-Thomas Flat-Polar Quartic', 'gnom' : 'Gnomonic', } supported_projections = [] @@ -78,7 +79,7 @@ supported_projections = ''.join(supported_projections) _cylproj = ['cyl','merc','mill','gall'] -_pseudocyl = ['moll','robin','sinu','mbtfpq'] +_pseudocyl = ['moll','robin','sinu','mbtfpq','vandg'] # projection specific parameters. projection_params = {'cyl' : 'corners only (no width/height)', @@ -106,6 +107,7 @@ 'sinu' : 'lon_0,lat_0,no corners or width/height', 'moll' : 'lon_0,lat_0,no corners or width/height', 'robin' : 'lon_0,lat_0,no corners or width/height', + 'vandg' : 'lon_0,lat_0,no corners or width/height', 'mbtfpq' : 'lon_0,lat_0,no corners or width/height', 'gnom' : 'lon_0,lat_0', } @@ -546,7 +548,7 @@ self.llcrnrlon = llcrnrlon; self.llcrnrlat = llcrnrlat self.urcrnrlon = urcrnrlon; self.urcrnrlat = urcrnrlat if width is not None or height is not None: - print 'warning: width and height keywords ignored for %s projection' % self.projection + print 'warning: width and height keywords ignored for %s projection' % _projnames[self.projection] elif projection in ['tmerc','gnom','cass','poly'] : if projection == 'gnom' and not projparams.has_key('R'): raise ValueError, 'gnomonic projection only works for perfect spheres - not ellipsoids' @@ -566,7 +568,7 @@ if lat_0 is None or lon_0 is None: raise ValueError, 'must specify lat_0 and lon_0 for Orthographic basemap' if width is not None or height is not None: - print 'warning: width and height keywords ignored for %s projection' % self.projection + print 'warning: width and height keywords ignored for %s projection' % _projnames[self.projection] if not using_corners: llcrnrlon = -180. llcrnrlat = -90. @@ -584,7 +586,7 @@ if lon_0 is None: raise ValueError, 'must specify lon_0 for Geostationary basemap' if width is not None or height is not None: - print 'warning: width and height keywords ignored for %s projection' % self.projection + print 'warning: width and height keywords ignored for %s projection' % _projnames[self.projection] if not using_corners: llcrnrlon = -180. llcrnrlat = -90. @@ -597,9 +599,9 @@ self.urcrnrlon = urcrnrlon; self.urcrnrlat = urcrnrlat elif projection in _pseudocyl: if lon_0 is None: - raise ValueError, 'must specify lon_0 for Robinson, Mollweide, or Sinusoidal basemap' + raise ValueError, 'must specify lon_0 for %s projection' % _projnames[self.projection] if width is not None or height is not None: - print 'warning: width and height keywords ignored for %s projection' % self.projection + print 'warning: width and height keywords ignored for %s projection' % _projnames[self.projection] llcrnrlon = -180. llcrnrlat = -90. urcrnrlon = 180 @@ -646,7 +648,7 @@ self.llcrnrlon = llcrnrlon; self.llcrnrlat = llcrnrlat self.urcrnrlon = urcrnrlon; self.urcrnrlat = urcrnrlat if width is not None or height is not None: - print 'warning: width and height keywords ignored for %s projection' % self.projection + print 'warning: width and height keywords ignored for %s projection' % _projnames[self.projection] elif projection == 'cyl': if not using_corners: llcrnrlon = -180. @@ -656,7 +658,7 @@ self.llcrnrlon = llcrnrlon; self.llcrnrlat = llcrnrlat self.urcrnrlon = urcrnrlon; self.urcrnrlat = urcrnrlat if width is not None or height is not None: - print 'warning: width and height keywords ignored for %s projection' % self.projection + print 'warning: width and height keywords ignored for %s projection' % _projnames[self.projection] else: raise ValueError(_unsupported_projection % projection) @@ -1039,13 +1041,14 @@ """ create map boundary polygon (in lat/lon and x/y coordinates) """ - nx = 100 - ny = 100 + nx = 100; ny = 100 + if self.projection == 'vandg': + nx = 10*nx; ny = 10*ny maptran = self if self.projection in ['ortho','geos']: # circular region. thetas = np.linspace(0.,2.*np.pi,2*nx*ny)[:-1] - if self.projection == 'ortho': + if self.projection == 'ortho': rminor = self.rmajor rmajor = self.rmajor else: @@ -1078,17 +1081,17 @@ # quasi-elliptical region. lon_0 = self.projparams['lon_0'] # left side - lats1 = np.linspace(-89.9,89.9,ny).tolist() + lats1 = np.linspace(-89.9999,89.9999,ny).tolist() lons1 = len(lats1)*[lon_0-179.9] # top. lons2 = np.linspace(lon_0-179.9,lon_0+179.9,nx).tolist() - lats2 = len(lons2)*[89.9] + lats2 = len(lons2)*[89.9999] # right side - lats3 = np.linspace(89.9,-89.9,ny).tolist() + lats3 = np.linspace(89.9999,-89.9999,ny).tolist() lons3 = len(lats3)*[lon_0+179.9] # bottom. lons4 = np.linspace(lon_0+179.9,lon_0-179.9,nx).tolist() - lats4 = len(lons4)*[-89.9] + lats4 = len(lons4)*[-89.9999] lons = np.array(lons1+lons2+lons3+lons4,np.float64) lats = np.array(lats1+lats2+lats3+lats4,np.float64) x, y = maptran(lons,lats) @@ -1206,20 +1209,22 @@ limb.set_zorder(zorder) elif self.projection in _pseudocyl: # elliptical region. nx = 100; ny = 100 + if self.projection == 'vandg': + nx = 10*nx; ny = 10*ny # quasi-elliptical region. lon_0 = self.projparams['lon_0'] # left side - lats1 = np.linspace(-89.9,89.9,ny).tolist() + lats1 = np.linspace(-89.9999,89.99999,ny).tolist() lons1 = len(lats1)*[lon_0-179.9] # top. - lons2 = np.linspace(lon_0-179.9,lon_0+179.9,nx).tolist() - lats2 = len(lons2)*[89.9] + lons2 = np.linspace(lon_0-179.9999,lon_0+179.9999,nx).tolist() + lats2 = len(lons2)*[89.9999] # right side - lats3 = np.linspace(89.9,-89.9,ny).tolist() - lons3 = len(lats3)*[lon_0+179.9] + lats3 = np.linspace(89.9999,-89.9999,ny).tolist() + lons3 = len(lats3)*[lon_0+179.9999] # bottom. - lons4 = np.linspace(lon_0+179.9,lon_0-179.9,nx).tolist() - lats4 = len(lons4)*[-89.9] + lons4 = np.linspace(lon_0+179.9999,lon_0-179.9999,nx).tolist() + lats4 = len(lons4)*[-89.9999] lons = np.array(lons1+lons2+lons3+lons4,np.float64) lats = np.array(lats1+lats2+lats3+lats4,np.float64) x, y = self(lons,lats) @@ -1781,12 +1786,13 @@ lines = [] if len(x) > 1 and len(y) > 1: # split into separate line segments if necessary. - # (not necessary for mercator or cylindrical or miller). + # (not necessary for cylindrical or pseudocylindricl projections) xd = (x[1:]-x[0:-1])**2 yd = (y[1:]-y[0:-1])**2 dist = np.sqrt(xd+yd) split = dist > 500000. - if np.sum(split) and self.projection not in _cylproj + _pseudocyl: + if np.sum(split) and self.projection not in \ + ['cyl', 'merc', 'mill', 'gall', 'moll', 'robin', 'sinu', 'mbtfpq']: ind = (np.compress(split,np.squeeze(split*np.indices(xd.shape)))+1).tolist() xl = [] yl = [] @@ -1814,9 +1820,9 @@ linecolls[circ] = (lines,[]) # draw labels for parallels # parallels not labelled for fulldisk orthographic or geostationary - if self.projection in ['ortho','geos'] and max(labels): - if self._fulldisk: - print 'Warning: Cannot label parallels on full-disk Orthographic or Geostationary basemap' + if self.projection in ['ortho','geos','vandg'] and max(labels): + if self.projection == 'vandg' or self._fulldisk: + print 'Warning: Cannot label parallels on %s basemap' % _projnames[self.projection] labels = [0,0,0,0] # search along edges of map to see if parallels intersect. # if so, find x,y location of intersection and draw a label there. @@ -2057,8 +2063,8 @@ # draw labels for meridians. # meridians not labelled for sinusoidal, mollweide, or # or full-disk orthographic/geostationary. - if self.projection in ['sinu','moll'] and max(labels): - print 'Warning: Cannot label meridians on Sinusoidal or Mollweide basemap' + if self.projection in ['sinu','moll','vandg'] and max(labels): + print 'Warning: Cannot label meridians on %s basemap' % _projnames[self.projection] labels = [0,0,0,0] if self.projection in ['ortho','geos'] and max(labels): if self._fulldisk: Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/proj.py =================================================================== --- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/proj.py 2008年09月30日 20:07:54 UTC (rev 6137) +++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/proj.py 2008年09月30日 20:14:38 UTC (rev 6138) @@ -7,7 +7,7 @@ _rad2dg = math.degrees(1.) _cylproj = ['cyl','merc','mill','gall'] -_pseudocyl = ['moll','robin','sinu','mbtfpq'] +_pseudocyl = ['moll','robin','sinu','mbtfpq','vandg'] _upper_right_out_of_bounds = ( 'the upper right corner of the plot is not in the map projection region') This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 6137 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6137&view=rev Author: mdboom Date: 2008年09月30日 20:07:54 +0000 (2008年9月30日) Log Message: ----------- [ 2138392 ] API doc for add_subplot() Also fixing numerous problems with the documentation build. It seems that the change in plot_directive.py to use the "code" module to run scripts interferes with i18n in Sphinx (due to the overloading of '_' as a symbol). Changed to use the fewer-moving-parts imp.load_module() instead. Modified Paths: -------------- trunk/matplotlib/doc/faq/howto_faq.rst trunk/matplotlib/doc/make.py trunk/matplotlib/doc/sphinxext/plot_directive.py trunk/matplotlib/examples/pylab_examples/findobj_demo.py trunk/matplotlib/lib/matplotlib/figure.py Modified: trunk/matplotlib/doc/faq/howto_faq.rst =================================================================== --- trunk/matplotlib/doc/faq/howto_faq.rst 2008年09月30日 17:29:03 UTC (rev 6136) +++ trunk/matplotlib/doc/faq/howto_faq.rst 2008年09月30日 20:07:54 UTC (rev 6137) @@ -117,7 +117,7 @@ How do I automatically make room for my tick labels? ==================================================== -In most use cases, it is enought to simpy change the subplots adjust +In most use cases, it is enough to simpy change the subplots adjust parameters as described in :ref:`howto-subplots-adjust`. But in some cases, you don't know ahead of time what your tick labels will be, or how large they will be (data and labels outside your control may be Modified: trunk/matplotlib/doc/make.py =================================================================== --- trunk/matplotlib/doc/make.py 2008年09月30日 17:29:03 UTC (rev 6136) +++ trunk/matplotlib/doc/make.py 2008年09月30日 20:07:54 UTC (rev 6137) @@ -85,7 +85,7 @@ for arg in sys.argv[1:]: func = funcd.get(arg) if func is None: - raise SystemExit('Do not know how to handle %s; valid args are'%( + raise SystemExit('Do not know how to handle %s; valid args are %s'%( arg, funcd.keys())) func() else: Modified: trunk/matplotlib/doc/sphinxext/plot_directive.py =================================================================== --- trunk/matplotlib/doc/sphinxext/plot_directive.py 2008年09月30日 17:29:03 UTC (rev 6136) +++ trunk/matplotlib/doc/sphinxext/plot_directive.py 2008年09月30日 20:07:54 UTC (rev 6137) @@ -13,7 +13,7 @@ source will be included inline, as well as a link to the source. """ -import sys, os, glob, shutil, code +import sys, os, glob, shutil, imp from docutils.parsers.rst import directives try: @@ -30,12 +30,10 @@ matplotlib.use('Agg') import matplotlib.pyplot as plt -#import IPython.Shell -#mplshell = IPython.Shell.MatplotlibShell('mpl') -console = code.InteractiveConsole() def runfile(fname): - source = file(fname).read() - return console.runsource(source) + fd = open(fname) + module = imp.load_module("__main__", fd, fname, ('py', 'r', imp.PY_SOURCE)) + return module options = {'alt': directives.unchanged, 'height': directives.length_or_unitless, Modified: trunk/matplotlib/examples/pylab_examples/findobj_demo.py =================================================================== --- trunk/matplotlib/examples/pylab_examples/findobj_demo.py 2008年09月30日 17:29:03 UTC (rev 6136) +++ trunk/matplotlib/examples/pylab_examples/findobj_demo.py 2008年09月30日 20:07:54 UTC (rev 6137) @@ -1,5 +1,5 @@ """ -Recursuvely find all objects that match some criteria +Recursively find all objects that match some criteria """ import numpy as np import matplotlib.pyplot as plt Modified: trunk/matplotlib/lib/matplotlib/figure.py =================================================================== --- trunk/matplotlib/lib/matplotlib/figure.py 2008年09月30日 17:29:03 UTC (rev 6136) +++ trunk/matplotlib/lib/matplotlib/figure.py 2008年09月30日 20:07:54 UTC (rev 6137) @@ -633,21 +633,23 @@ fig.add_subplot(111, polar=True) # add a polar subplot fig.add_subplot(sub) # add Subplot instance sub - *kwargs* are legal :class:`!matplotlib.axes.Axes` kwargs plus *projection*, which chooses - a projection type for the axes. (For backward compatibility, - *polar=True* may also be provided, which is equivalent to - *projection='polar'*). Valid values for *projection* are: %s. - Some of these projections support additional *kwargs*, which may - be provided to :meth:`add_axes`. + *kwargs* are legal :class:`!matplotlib.axes.Axes` kwargs plus + *projection*, which chooses a projection type for the axes. + (For backward compatibility, *polar=True* may also be + provided, which is equivalent to *projection='polar'*). Valid + values for *projection* are: %s. Some of these projections + support additional *kwargs*, which may be provided to + :meth:`add_axes`. The :class:`~matplotlib.axes.Axes` instance will be returned. - If the figure already has a subplot with key *args*, *kwargs* then it will - simply make that subplot current and return it + If the figure already has a subplot with key (*args*, + *kwargs*) then it will simply make that subplot current and + return it. The following kwargs are supported: %s - """ % (", ".join(get_projection_names()), "%(Axes)s") + """ key = self._make_key(*args, **kwargs) if self._seen.has_key(key): @@ -680,7 +682,8 @@ self.sca(a) self._seen[key] = a return a - add_subplot.__doc__ = dedent(add_subplot.__doc__) % artist.kwdocd + add_subplot.__doc__ = dedent(add_subplot.__doc__) % ( + ", ".join(get_projection_names()), "%(Axes)s") % artist.kwdocd def clf(self): """ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 6136 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6136&view=rev Author: jswhit Date: 2008年09月30日 17:29:03 +0000 (2008年9月30日) Log Message: ----------- added two new projections ('mbtfpq' and 'gall') Modified Paths: -------------- trunk/toolkits/basemap/Changelog trunk/toolkits/basemap/examples/plot_tissot.py trunk/toolkits/basemap/examples/test.py trunk/toolkits/basemap/examples/warpimage.py trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py trunk/toolkits/basemap/lib/mpl_toolkits/basemap/proj.py Modified: trunk/toolkits/basemap/Changelog =================================================================== --- trunk/toolkits/basemap/Changelog 2008年09月30日 11:18:10 UTC (rev 6135) +++ trunk/toolkits/basemap/Changelog 2008年09月30日 17:29:03 UTC (rev 6136) @@ -1,4 +1,7 @@ version 0.99.2 (not yet released) + * Added McBryde-Thomas Flat Polar Quartic (projection = + 'mbtfpq') and Gall Stereographic Cylindrical (projection = + 'gall'). * fix warpimage and bluemarble methods for projection = 'cyl', 'robin', 'moll' and 'sinu'. * bugfix patch for rotate_vector from David Huard. David Modified: trunk/toolkits/basemap/examples/plot_tissot.py =================================================================== --- trunk/toolkits/basemap/examples/plot_tissot.py 2008年09月30日 11:18:10 UTC (rev 6135) +++ trunk/toolkits/basemap/examples/plot_tissot.py 2008年09月30日 17:29:03 UTC (rev 6136) @@ -25,8 +25,9 @@ m5 = Basemap(lon_0=270,lat_0=90,boundinglat=10,projection='nplaea') m6 = Basemap(lon_0=0,projection='moll') m7 = Basemap(lon_0=0,projection='robin') +m8 = Basemap(lon_0=0,projection='mbtfpq') -for m in [m1,m2,m3,m4,m5,m6,m7]: +for m in [m1,m2,m3,m4,m5,m6,m7,m8]: # make a new figure. fig = plt.figure() # draw "circles" at specified longitudes and latitudes. Modified: trunk/toolkits/basemap/examples/test.py =================================================================== --- trunk/toolkits/basemap/examples/test.py 2008年09月30日 11:18:10 UTC (rev 6135) +++ trunk/toolkits/basemap/examples/test.py 2008年09月30日 17:29:03 UTC (rev 6136) @@ -75,6 +75,26 @@ # create new figure fig=plt.figure() +# setup gall stereographic cylindrical map projection. +m = Basemap(llcrnrlon=-180.,llcrnrlat=-90,urcrnrlon=180.,urcrnrlat=90.,\ + resolution='c',area_thresh=10000.,projection='gall') +# transform to nx x ny regularly spaced native projection grid +nx = len(lons); ny = len(lats) +topodat = m.transform_scalar(topoin,lons,lats,nx,ny) +fig.add_axes([0.1,0.1,0.75,0.75]) +# plot image over map. +im = m.imshow(topodat,plt.cm.jet) +m.drawcoastlines() +# draw parallels +m.drawparallels(circles,labels=[1,1,1,1]) +# draw meridians +m.drawmeridians(meridians,labels=[1,1,1,1]) +plt.title('Gall Stereographic Cylindrical',y=1.1) +print 'plotting Gall Stereographic Cylindrical example ...' +print m.proj4string + +# create new figure +fig=plt.figure() # setup mercator map projection (-80 to +80). m = Basemap(llcrnrlon=-180.,llcrnrlat=-80,urcrnrlon=180.,urcrnrlat=80.,\ resolution='c',area_thresh=10000.,projection='merc',\ @@ -615,6 +635,33 @@ plt.title('Robinson') print 'plotting Robinson example ...' print m.proj4string + +# create new figure +fig=plt.figure() +# setup of basemap ('mbtfpq' = McBryde-Thomas Flat Polar Quartic projection) +m = Basemap(projection='mbtfpq', + resolution='c',area_thresh=10000.,lon_0=0.5*(lonsin[0]+lonsin[-1])) +ax = fig.add_axes([0.1,0.1,0.7,0.7]) +# plot image over map with pcolormesh. +x,y = m(*np.meshgrid(lonsin,latsin)) +p = m.pcolormesh(x,y,topodatin,shading='flat') +pos = ax.get_position() +l, b, w, h = pos.bounds +cax = plt.axes([l+w+0.05, b, 0.05, h]) # setup colorbar axes. +plt.colorbar(cax=cax) # draw colorbar +plt.axes(ax) # make the original axes current again +# draw coastlines and political boundaries. +m.drawcoastlines() +# draw parallels and meridians +parallels = np.arange(-60.,90,30.) +m.drawparallels(parallels,labels=[1,0,0,0]) +meridians = np.arange(0.,360.,60.) +m.drawmeridians(meridians,labels=[0,0,0,1],fontsize=8) +# draw boundary around map region. +m.drawmapboundary() +plt.title('McBryde-Thomas Flat Polar Quartic') +print 'plotting McBryde-Thomas Flat Polar Quartic example ...' +print m.proj4string plt.show() Modified: trunk/toolkits/basemap/examples/warpimage.py =================================================================== --- trunk/toolkits/basemap/examples/warpimage.py 2008年09月30日 11:18:10 UTC (rev 6135) +++ trunk/toolkits/basemap/examples/warpimage.py 2008年09月30日 17:29:03 UTC (rev 6136) @@ -22,16 +22,16 @@ # create new figure fig=plt.figure() -# define orthographic projection centered on North America. -m = Basemap(projection='robin',lon_0=-100,resolution='l') +# define projection centered on North America. +m = Basemap(projection='mbtfpq',lon_0=-100,resolution='l') m.bluemarble() # draw coastlines. m.drawcoastlines(linewidth=0.5,color='0.5') # draw lat/lon grid lines every 30 degrees. m.drawmeridians(np.arange(0,360,60),color='0.5') m.drawparallels(np.arange(-90,90,30),color='0.5') -plt.title("Blue Marble image warped from 'cyl' to 'robinson' projection",fontsize=12) -print 'warp to robinson map ...' +plt.title("Blue Marble image warped from 'cyl' to 'mbtfpq' projection",fontsize=12) +print 'warp to McBryde-Thomas Flat-Polar Quartic map ...' # create new figure fig=plt.figure() Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py =================================================================== --- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2008年09月30日 11:18:10 UTC (rev 6135) +++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2008年09月30日 17:29:03 UTC (rev 6136) @@ -49,6 +49,7 @@ 'tmerc' : 'Transverse Mercator', 'omerc' : 'Oblique Mercator', 'mill' : 'Miller Cylindrical', + 'gall' : 'Gall Stereographic Cylindrical', 'lcc' : 'Lambert Conformal', 'laea' : 'Lambert Azimuthal Equal Area', 'nplaea' : 'North-Polar Lambert Azimuthal', @@ -68,6 +69,7 @@ 'sinu' : 'Sinusoidal', 'moll' : 'Mollweide', 'robin' : 'Robinson', + 'mbtfpq' : 'McBryde-Thomas Flat-Polar Quartic', 'gnom' : 'Gnomonic', } supported_projections = [] @@ -75,12 +77,16 @@ supported_projections.append(" %-17s%-40s\n" % (_items)) supported_projections = ''.join(supported_projections) +_cylproj = ['cyl','merc','mill','gall'] +_pseudocyl = ['moll','robin','sinu','mbtfpq'] + # projection specific parameters. projection_params = {'cyl' : 'corners only (no width/height)', 'merc' : 'corners plus lat_ts (no width/height)', 'tmerc' : 'lon_0,lat_0', 'omerc' : 'lon_0,lat_0,lat_1,lat_2,lon_1,lon_2,no_rot', 'mill' : 'corners only (no width/height)', + 'gall' : 'corners only (no width/height)', 'lcc' : 'lon_0,lat_0,lat_1,lat_2', 'laea' : 'lon_0,lat_0', 'nplaea' : 'bounding_lat,lon_0,lat_0,no corners or width/height', @@ -100,6 +106,7 @@ 'sinu' : 'lon_0,lat_0,no corners or width/height', 'moll' : 'lon_0,lat_0,no corners or width/height', 'robin' : 'lon_0,lat_0,no corners or width/height', + 'mbtfpq' : 'lon_0,lat_0,no corners or width/height', 'gnom' : 'lon_0,lat_0', } @@ -160,7 +167,7 @@ ============== ==================================================== For ``sinu``, ``moll``, ``npstere``, ``spstere``, ``nplaea``, ``splaea``, - ``npaeqd``, ``spaeqd`` or ``robin``, the values of + ``npaeqd``, ``spaeqd``, ``robin`` or ``mbtfpq``, the values of llcrnrlon, llcrnrlat, urcrnrlon, urcrnrlat, width and height are ignored (because either they are computed internally, or entire globe is always plotted). @@ -588,7 +595,7 @@ self._fulldisk = False self.llcrnrlon = llcrnrlon; self.llcrnrlat = llcrnrlat self.urcrnrlon = urcrnrlon; self.urcrnrlat = urcrnrlat - elif projection in ['moll','robin','sinu']: + elif projection in _pseudocyl: if lon_0 is None: raise ValueError, 'must specify lon_0 for Robinson, Mollweide, or Sinusoidal basemap' if width is not None or height is not None: @@ -630,7 +637,7 @@ llcrnrlon,llcrnrlat,urcrnrlon,urcrnrlat = _choosecorners(width,height,**projparams) self.llcrnrlon = llcrnrlon; self.llcrnrlat = llcrnrlat self.urcrnrlon = urcrnrlon; self.urcrnrlat = urcrnrlat - elif projection == 'mill': + elif projection in ['mill','gall']: if not using_corners: llcrnrlon = -180. llcrnrlat = -90. @@ -710,10 +717,10 @@ self.urcrnrx = proj.urcrnrx self.urcrnry = proj.urcrnry # set min/max lats for projection domain. - if projection in ['mill','cyl','merc']: + if projection in _cylproj: self.latmin = self.llcrnrlat self.latmax = self.urcrnrlat - elif projection in ['ortho','geos','moll','robin','sinu']: + elif projection in ['ortho','geos'] + _pseudocyl: self.latmin = -90. self.latmax = 90. else: @@ -759,7 +766,7 @@ yd = (y[1:]-y[0:-1])**2 dist = np.sqrt(xd+yd) split = dist > 5000000. - if np.sum(split) and self.projection not in ['merc','cyl','mill']: + if np.sum(split) and self.projection not in _cylproj: ind = (np.compress(split,np.squeeze(split*np.indices(xd.shape)))+1).tolist() iprev = 0 ind.append(len(xd)) @@ -838,8 +845,7 @@ containsPole = hasNP or hasSP # these projections cannot cross pole. if containsPole and\ - self.projection in ['merc','mill','cyl','robin','moll','sinu','geos']: - #self.projection in ['tmerc','omerc','cass','merc','mill','cyl','robin','moll','sinu','geos']: + self.projection in _cylproj + _pseudocyl + ['geos']: raise ValueError('%s projection cannot cross pole'%(self.projection)) # make sure orthographic or gnomonic projection has containsPole=True # we will compute the intersections in stereographic @@ -1068,7 +1074,7 @@ projparms['x_0']=-llcrnrx projparms['y_0']=-llcrnry maptran = pyproj.Proj(projparms) - elif self.projection in ['moll','robin','sinu']: + elif self.projection in _pseudocyl: # quasi-elliptical region. lon_0 = self.projparams['lon_0'] # left side @@ -1110,7 +1116,7 @@ b[:,0]=[self.xmin,self.xmin,self.xmax,self.xmax] b[:,1]=[self.ymin,self.ymax,self.ymax,self.ymin] boundaryxy = _geoslib.Polygon(b) - if self.projection in ['mill','merc','cyl']: + if self.projection in _cylproj: # make sure map boundary doesn't quite include pole. if self.urcrnrlat > 89.9999: urcrnrlat = 89.9999 @@ -1127,7 +1133,7 @@ b[:,0]=x; b[:,1]=y boundaryxy = _geoslib.Polygon(b) else: - if self.projection not in ['moll','robin','sinu']: + if self.projection not in _pseudocyl: lons, lats = maptran(x,y,inverse=True) # fix lons so there are no jumps. n = 1 @@ -1198,7 +1204,7 @@ limb.set_clip_on(False) if zorder is not None: limb.set_zorder(zorder) - elif self.projection in ['moll','robin','sinu']: # elliptical region. + elif self.projection in _pseudocyl: # elliptical region. nx = 100; ny = 100 # quasi-elliptical region. lon_0 = self.projparams['lon_0'] @@ -1738,7 +1744,7 @@ if xoffset is None: xoffset = (self.urcrnrx-self.llcrnrx)/100. - if self.projection in ['merc','cyl','mill','moll','robin','sinu']: + if self.projection in _cylproj + _pseudocyl: lons = np.arange(self.llcrnrlon,self.urcrnrlon+0.01,0.01) elif self.projection in ['tmerc']: lon_0 = self.projparams['lon_0'] @@ -1751,7 +1757,7 @@ circlesl = circles.tolist() except: circlesl = circles - if self.projection not in ['merc','cyl','mill','moll','robin','sinu']: + if self.projection not in _cylproj + _pseudocyl: if max(circlesl) > 0 and latmax not in circlesl: circlesl.append(latmax) if min(circlesl) < 0 and -latmax not in circlesl: @@ -1780,7 +1786,7 @@ yd = (y[1:]-y[0:-1])**2 dist = np.sqrt(xd+yd) split = dist > 500000. - if np.sum(split) and self.projection not in ['merc','cyl','mill','moll','robin','sinu']: + if np.sum(split) and self.projection not in _cylproj + _pseudocyl: ind = (np.compress(split,np.squeeze(split*np.indices(xd.shape)))+1).tolist() xl = [] yl = [] @@ -1816,12 +1822,12 @@ # if so, find x,y location of intersection and draw a label there. dx = (self.xmax-self.xmin)/1000. dy = (self.ymax-self.ymin)/1000. - if self.projection in ['moll','robin','sinu']: + if self.projection in _pseudocyl: lon_0 = self.projparams['lon_0'] for dolab,side in zip(labels,['l','r','t','b']): if not dolab: continue # for cylindrical projections, don't draw parallels on top or bottom. - if self.projection in ['cyl','merc','mill','moll','robin','sinu'] and side in ['t','b']: continue + if self.projection in _cylproj + _pseudocyl and side in ['t','b']: continue if side in ['l','r']: nmax = int((self.ymax-self.ymin)/dy+1) yy = np.linspace(self.llcrnry,self.urcrnry,nmax) @@ -1897,14 +1903,14 @@ if n >= 0: t = None if side == 'l': - if self.projection in ['moll','robin','sinu']: + if self.projection in _pseudocyl: xlab,ylab = self(lon_0-179.9,lat) else: xlab = self.llcrnrx xlab = xlab-xoffset t = ax.text(xlab,yy[n],latlab,horizontalalignment='right',verticalalignment='center',**kwargs) elif side == 'r': - if self.projection in ['moll','robin','sinu']: + if self.projection in _pseudocyl: xlab,ylab = self(lon_0+179.9,lat) else: xlab = self.urcrnrx @@ -1994,7 +2000,7 @@ if xoffset is None: xoffset = (self.urcrnrx-self.llcrnrx)/100. - if self.projection not in ['merc','cyl','mill','moll','robin','sinu']: + if self.projection not in _cylproj + _pseudocyl: lats = np.arange(-latmax,latmax+0.01,0.01) else: lats = np.arange(-90,90.01,0.01) @@ -2022,7 +2028,7 @@ yd = (y[1:]-y[0:-1])**2 dist = np.sqrt(xd+yd) split = dist > 500000. - if np.sum(split) and self.projection not in ['merc','cyl','mill','moll','robin','sinu']: + if np.sum(split) and self.projection not in _cylproj + _pseudocyl: ind = (np.compress(split,np.squeeze(split*np.indices(xd.shape)))+1).tolist() xl = [] yl = [] @@ -2062,14 +2068,14 @@ # if so, find x,y location of intersection and draw a label there. dx = (self.xmax-self.xmin)/1000. dy = (self.ymax-self.ymin)/1000. - if self.projection in ['moll','sinu','robin']: + if self.projection in _pseudocyl: lon_0 = self.projparams['lon_0'] xmin,ymin = self(lon_0-179.9,-90) xmax,ymax = self(lon_0+179.9,90) for dolab,side in zip(labels,['l','r','t','b']): if not dolab: continue # for cylindrical projections, don't draw meridians on left or right. - if self.projection in ['cyl','merc','mill','sinu','robin','moll'] and side in ['l','r']: continue + if self.projection in _cylproj + _pseudocyl and side in ['l','r']: continue if side in ['l','r']: nmax = int((self.ymax-self.ymin)/dy+1) yy = np.linspace(self.llcrnry,self.urcrnry,nmax) @@ -2085,7 +2091,10 @@ lons = [(lon+360) % 360 for lon in lons] else: nmax = int((self.xmax-self.xmin)/dx+1) - xx = np.linspace(self.llcrnrx,self.urcrnrx,nmax) + if self.projection in _pseudocyl: + xx = np.linspace(xmin,xmax,nmax) + else: + xx = np.linspace(self.llcrnrx,self.urcrnrx,nmax) if side == 'b': lons,lats = self(xx,self.llcrnry*np.ones(xx.shape,np.float32),inverse=True) lons = lons.tolist(); lats = lats.tolist() @@ -2141,7 +2150,7 @@ for i,n in enumerate([nl,nr]): lat = lats[n]/100. # no meridians > latmax for projections other than merc,cyl,miller. - if self.projection not in ['merc','cyl','mill'] and lat > latmax: continue + if self.projection not in _cylproj and lat > latmax: continue # don't bother if close to the first label. if i and abs(nr-nl) < 100: continue if n >= 0: @@ -2151,11 +2160,9 @@ elif side == 'r': t = ax.text(self.urcrnrx+xoffset,yy[n],lonlab,horizontalalignment='left',verticalalignment='center',**kwargs) elif side == 'b': - if self.projection != 'robin' or (xx[n] > xmin and xx[n] < xmax): - t = ax.text(xx[n],self.llcrnry-yoffset,lonlab,horizontalalignment='center',verticalalignment='top',**kwargs) + t = ax.text(xx[n],self.llcrnry-yoffset,lonlab,horizontalalignment='center',verticalalignment='top',**kwargs) else: - if self.projection != 'robin' or (xx[n] > xmin and xx[n] < xmax): - t = ax.text(xx[n],self.urcrnry+yoffset,lonlab,horizontalalignment='center',verticalalignment='bottom',**kwargs) + t = ax.text(xx[n],self.urcrnry+yoffset,lonlab,horizontalalignment='center',verticalalignment='bottom',**kwargs) if t is not None: linecolls[lon][1].append(t) # set axes limits to fit map region. @@ -2313,7 +2320,7 @@ if min(delon) < 0. or min(delat) < 0.: raise ValueError, 'lons and lats must be increasing!' # check that lons in -180,180 for non-cylindrical projections. - if self.projection not in ['cyl','merc','mill']: + if self.projection not in _cylproj: lonsa = np.array(lons) count = np.sum(lonsa < -180.00001) + np.sum(lonsa > 180.00001) if count > 1: @@ -2384,7 +2391,7 @@ if min(delon) < 0. or min(delat) < 0.: raise ValueError, 'lons and lats must be increasing!' # check that lons in -180,180 for non-cylindrical projections. - if self.projection not in ['cyl','merc','mill']: + if self.projection not in _cylproj: lonsa = np.array(lons) count = np.sum(lonsa < -180.00001) + np.sum(lonsa > 180.00001) if count > 1: @@ -2516,7 +2523,7 @@ ax.set_xlim((self.llcrnrx, self.urcrnrx)) ax.set_ylim((self.llcrnry, self.urcrnry)) # turn off axes frame for non-rectangular projections. - if self.projection in ['moll','robin','sinu']: + if self.projection in _pseudocyl: ax.set_frame_on(False) if self.projection in ['ortho','geos'] and self._fulldisk: ax.set_frame_on(False) @@ -2782,7 +2789,7 @@ # print warning suggesting that the data be shifted in longitude # with the shiftgrid function. # only do this check for global projections. - if self.projection in ['merc','cyl','mill','moll','robin','sinu']: + if self.projection in _cylproj + _pseudocyl: xx = x[x.shape[0]/2,:] condition = (xx >= self.xmin) & (xx <= self.xmax) xl = xx.compress(condition).tolist() @@ -2855,7 +2862,7 @@ # print warning suggesting that the data be shifted in longitude # with the shiftgrid function. # only do this check for global projections. - if self.projection in ['merc','cyl','mill','moll','robin','sinu']: + if self.projection in _cylproj + _pseudocyl: xx = x[x.shape[0]/2,:] condition = (xx >= self.xmin) & (xx <= self.xmax) xl = xx.compress(condition).tolist() @@ -3101,7 +3108,7 @@ lsmask_lats,nx,ny,returnxy=True,order=0,masked=255) # for these projections, points outside the projection # limb have to be set to transparent manually. - if self.projection in ['moll','robin','sinu']: + if self.projection in _pseudocyl: lons, lats = self(x, y, inverse=True) lon_0 = self.projparams['lon_0'] lats = lats[:,nx/2] @@ -3207,7 +3214,7 @@ self._bm_lats = np.arange(-90.+0.5*delta,90.,delta) # is it a cylindrical projection whose limits lie # outside the limits of the image? - cylproj = self.projection in ['mill','cyl','merc'] and \ + cylproj = self.projection in _cylproj and \ (self.urcrnrlon > self._bm_lons[-1] or \ self.llcrnrlon < self._bm_lons[0]) # if pil_to_array returns a 2D array, it's a grayscale image. @@ -3260,8 +3267,8 @@ ma.masked_array(self._bm_rgba_warped,mask=mask) # make points outside projection limb transparent. self._bm_rgba_warped = self._bm_rgba_warped.filled(0.) - # treat mollweide, robinson and sinusoidal. - elif self.projection in ['moll','robin','sinu']: + # treat pseudo-cyl projections such as mollweide, robinson and sinusoidal. + elif self.projection in _pseudocyl: lonsr,latsr = self(x,y,inverse=True) mask = ma.zeros((ny,nx,4),np.int8) lon_0 = self.projparams['lon_0'] Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/proj.py =================================================================== --- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/proj.py 2008年09月30日 11:18:10 UTC (rev 6135) +++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/proj.py 2008年09月30日 17:29:03 UTC (rev 6136) @@ -6,6 +6,9 @@ _dg2rad = math.radians(1.) _rad2dg = math.degrees(1.) +_cylproj = ['cyl','merc','mill','gall'] +_pseudocyl = ['moll','robin','sinu','mbtfpq'] + _upper_right_out_of_bounds = ( 'the upper right corner of the plot is not in the map projection region') @@ -67,7 +70,7 @@ self.esq = (self.rmajor**2 - self.rminor**2)/self.rmajor**2 self.llcrnrlon = llcrnrlon self.llcrnrlat = llcrnrlat - if self.projection not in ['cyl','ortho','geos','moll','robin','sinu']: + if self.projection not in ['ortho','geos','cyl'] + _pseudocyl: self._proj4 = pyproj.Proj(projparams) llcrnrx, llcrnry = self(llcrnrlon,llcrnrlat) elif self.projection == 'cyl': @@ -119,7 +122,7 @@ llcrnrx, llcrnry = self(llcrnrlon,llcrnrlat) if llcrnrx > 1.e20 or llcrnry > 1.e20: raise ValueError(_lower_left_out_of_bounds) - elif self.projection in ['moll','robin','sinu']: + elif self.projection in _pseudocyl: self._proj4 = pyproj.Proj(projparams) xtmp,urcrnry = self(projparams['lon_0'],90.) urcrnrx,xtmp = self(projparams['lon_0']+180.,0) @@ -140,7 +143,7 @@ if urcrnrislatlon: self.urcrnrlon = urcrnrlon self.urcrnrlat = urcrnrlat - if self.projection not in ['ortho','geos','moll','robin','sinu']: + if self.projection not in ['ortho','geos'] + _pseudocyl: urcrnrx,urcrnry = self(urcrnrlon,urcrnrlat) elif self.projection == 'ortho': if self._fulldisk: @@ -158,7 +161,7 @@ urcrnrx,urcrnry = self(urcrnrlon,urcrnrlat) if urcrnrx > 1.e20 or urcrnry > 1.e20: raise ValueError(_upper_right_out_of_bounds) - elif self.projection in ['moll','robin','sinu']: + elif self.projection in _pseudocyl: xtmp,urcrnry = self(projparams['lon_0'],90.) urcrnrx,xtmp = self(projparams['lon_0']+180.,0) else: @@ -216,7 +219,7 @@ else: outx,outy = self._proj4(x, y, inverse=inverse) if inverse: - if self.projection in ['merc','mill']: + if self.projection in ['merc','mill','gall']: if self.projection == 'merc': coslat = math.cos(math.radians(self.projparams['lat_ts'])) sinlat = math.sin(math.radians(self.projparams['lat_ts'])) @@ -234,7 +237,7 @@ except: # x a sequence outx = [_rad2dg*(xi/rcurv) + self.llcrnrlon for xi in x] else: - if self.projection in ['merc','mill']: + if self.projection in ['merc','mill','gall']: if self.projection == 'merc': coslat = math.cos(math.radians(self.projparams['lat_ts'])) sinlat = math.sin(math.radians(self.projparams['lat_ts'])) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 6135 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6135&view=rev Author: jdh2358 Date: 2008年09月30日 11:18:10 +0000 (2008年9月30日) Log Message: ----------- removed numerical_methods from imports Modified Paths: -------------- trunk/matplotlib/examples/pylab_examples/fill_between.py trunk/matplotlib/examples/pylab_examples/interp_demo.py trunk/matplotlib/lib/matplotlib/__init__.py trunk/matplotlib/lib/matplotlib/cbook.py trunk/matplotlib/lib/matplotlib/dates.py trunk/matplotlib/matplotlibrc.template Modified: trunk/matplotlib/examples/pylab_examples/fill_between.py =================================================================== --- trunk/matplotlib/examples/pylab_examples/fill_between.py 2008年09月29日 17:30:14 UTC (rev 6134) +++ trunk/matplotlib/examples/pylab_examples/fill_between.py 2008年09月30日 11:18:10 UTC (rev 6135) @@ -1,5 +1,5 @@ #!/usr/bin/env python -import matplotlib.numerical_methods as numerical_methods +import matplotlib.mlab as mlab from pylab import figure, show import numpy as np @@ -13,15 +13,15 @@ ax3 = fig.add_subplot(313) -xs, ys = numerical_methods.poly_between(x, 0, y1) +xs, ys = mlab.poly_between(x, 0, y1) ax.fill(xs, ys) ax.set_ylabel('between y1 and 0') -xs, ys = numerical_methods.poly_between(x, y1, 1) +xs, ys = mlab.poly_between(x, y1, 1) ax2.fill(xs, ys) ax2.set_ylabel('between y1 and 1') -xs, ys = numerical_methods.poly_between(x, y1, y2) +xs, ys = mlab.poly_between(x, y1, y2) ax3.fill(xs, ys) ax3.set_ylabel('between y1 and y2') ax3.set_xlabel('x') Modified: trunk/matplotlib/examples/pylab_examples/interp_demo.py =================================================================== --- trunk/matplotlib/examples/pylab_examples/interp_demo.py 2008年09月29日 17:30:14 UTC (rev 6134) +++ trunk/matplotlib/examples/pylab_examples/interp_demo.py 2008年09月30日 11:18:10 UTC (rev 6135) @@ -1,6 +1,6 @@ from matplotlib.pyplot import figure, show from numpy import pi, sin, linspace -from matplotlib.numerical_methods import stineman_interp +from matplotlib.mlab import stineman_interp x = linspace(0,2*pi,20); y = sin(x); yp = None Modified: trunk/matplotlib/lib/matplotlib/__init__.py =================================================================== --- trunk/matplotlib/lib/matplotlib/__init__.py 2008年09月29日 17:30:14 UTC (rev 6134) +++ trunk/matplotlib/lib/matplotlib/__init__.py 2008年09月30日 11:18:10 UTC (rev 6135) @@ -131,12 +131,9 @@ major, minor1, minor2, s, tmp = sys.version_info _python24 = major>=2 and minor1>=4 -try: - import datetime - import dateutil - import pytz -except ImportError: _havedate = False -else: _havedate = True +# the havedate check was a legacy from old matplotlib which preceeded +# datetime support +_havedate = True #try: # import pkg_resources # pkg_resources is part of setuptools Modified: trunk/matplotlib/lib/matplotlib/cbook.py =================================================================== --- trunk/matplotlib/lib/matplotlib/cbook.py 2008年09月29日 17:30:14 UTC (rev 6134) +++ trunk/matplotlib/lib/matplotlib/cbook.py 2008年09月30日 11:18:10 UTC (rev 6135) @@ -1307,6 +1307,77 @@ ls_mapper = dict(_linestyles) ls_mapper.update([(ls[1], ls[0]) for ls in _linestyles]) +def less_simple_linear_interpolation( x, y, xi, extrap=False ): + """ + This function has been moved to matplotlib.mlab -- please import + it from there + """ + # deprecated from cbook in 0.98.4 + warnings.warn('less_simple_linear_interpolation has been moved to matplotlib.mlab -- please import it from there', DeprecationWarning) + import matplotlib.mlab as mlab + return mlab.less_simple_linear_interpolation( x, y, xi, extrap=extrap ) + +def isvector(X): + """ + This function has been moved to matplotlib.mlab -- please import + it from there + """ + # deprecated from cbook in 0.98.4 + warnings.warn('isvector has been moved to matplotlib.mlab -- please import it from there', DeprecationWarning) + import matplotlib.mlab as mlab + return mlab.isvector( x, y, xi, extrap=extrap ) + +def vector_lengths( X, P=2., axis=None ): + """ + This function has been moved to matplotlib.mlab -- please import + it from there + """ + # deprecated from cbook in 0.98.4 + warnings.warn('vector_lengths has been moved to matplotlib.mlab -- please import it from there', DeprecationWarning) + import matplotlib.mlab as mlab + return mlab.vector_lengths( X, P=2., axis=axis ) + +def distances_along_curve( X ): + """ + This function has been moved to matplotlib.mlab -- please import + it from there + """ + # deprecated from cbook in 0.98.4 + warnings.warn('distances_along_curve has been moved to matplotlib.mlab -- please import it from there', DeprecationWarning) + import matplotlib.mlab as mlab + return mlab.distances_along_curve( X ) + +def path_length(X): + """ + This function has been moved to matplotlib.mlab -- please import + it from there + """ + # deprecated from cbook in 0.98.4 + warnings.warn('path_length has been moved to matplotlib.mlab -- please import it from there', DeprecationWarning) + import matplotlib.mlab as mlab + return mlab.path_length(X) + +def is_closed_polygon(X): + """ + This function has been moved to matplotlib.mlab -- please import + it from there + """ + # deprecated from cbook in 0.98.4 + warnings.warn('is_closed_polygon has been moved to matplotlib.mlab -- please import it from there', DeprecationWarning) + import matplotlib.mlab as mlab + return mlab.is_closed_polygon(X) + +def quad2cubic(q0x, q0y, q1x, q1y, q2x, q2y): + """ + This function has been moved to matplotlib.mlab -- please import + it from there + """ + # deprecated from cbook in 0.98.4 + warnings.warn('quad2cubic has been moved to matplotlib.mlab -- please import it from there', DeprecationWarning) + import matplotlib.mlab as mlab + return mlab.quad2cubic(q0x, q0y, q1x, q1y, q2x, q2y) + + if __name__=='__main__': assert( allequal([1,1,1]) ) assert(not allequal([1,1,0]) ) Modified: trunk/matplotlib/lib/matplotlib/dates.py =================================================================== --- trunk/matplotlib/lib/matplotlib/dates.py 2008年09月29日 17:30:14 UTC (rev 6134) +++ trunk/matplotlib/lib/matplotlib/dates.py 2008年09月30日 11:18:10 UTC (rev 6135) @@ -79,6 +79,14 @@ import re, time, math, datetime import pytz + +# compatability for 2008c and older versions +try: + import pytz.zoneinfo +except ImportError: + pytz.zoneinfo = pytz.tzinfo + pytz.zoneinfo.UTC = pytz.UTC + import matplotlib import numpy as np Modified: trunk/matplotlib/matplotlibrc.template =================================================================== --- trunk/matplotlib/matplotlibrc.template 2008年09月29日 17:30:14 UTC (rev 6134) +++ trunk/matplotlib/matplotlibrc.template 2008年09月30日 11:18:10 UTC (rev 6135) @@ -251,12 +251,12 @@ # The figure subplot parameters. All dimensions are fraction of the # figure width or height -#figure.subplot.left : 0.125 # the left side of the subplots of the figure -#figure.subplot.right : 0.9 # the right side of the subplots of the figure -#figure.subplot.bottom : 0.1 # the bottom of the subplots of the figure -#figure.subplot.top : 0.9 # the top of the subplots of the figure -#figure.subplot.wspace : 0.2 # the amount of width reserved for blank space between subplots -#figure.subplot.hspace : 0.2 # the amount of height reserved for white space between subplots +#figure.subplot.left : 0.125 # the left side of the subplots of the figure +#figure.subplot.right : 0.9 # the right side of the subplots of the figure +#figure.subplot.bottom : 0.1 # the bottom of the subplots of the figure +#figure.subplot.top : 0.9 # the top of the subplots of the figure +#figure.subplot.wspace : 0.2 # the amount of width reserved for blank space between subplots +#figure.subplot.hspace : 0.2 # the amount of height reserved for white space between subplots ### IMAGES #image.aspect : equal # equal | auto | a number @@ -272,7 +272,7 @@ ### SAVING FIGURES #path.simplify : False # When True, simplify paths in vector backends, such as PDF, PS and SVG -# the default savefig params can be different for the GUI backends. +# the default savefig params can be different from the display params # Eg, you may want a higher resolution, or to make the figure # background white #savefig.dpi : 100 # figure dots per inch @@ -308,12 +308,12 @@ # Set the verbose flags. This controls how much information # matplotlib gives you at runtime and where it goes. The verbosity # levels are: silent, helpful, debug, debug-annoying. Any level is -# inclusive of all the levels below it. If you setting is debug, +# inclusive of all the levels below it. If your setting is "debug", # you'll get all the debug and helpful messages. When submitting -# problems to the mailing-list, please set verbose to helpful or debug +# problems to the mailing-list, please set verbose to "helpful" or "debug" # and paste the output into your report. # -# The fileo gives the destination for any calls to verbose.report. +# The "fileo" gives the destination for any calls to verbose.report. # These objects can a filename, or a filehandle like sys.stdout. # # You can override the rc default verbosity from the command line by This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 6134 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6134&view=rev Author: jswhit Date: 2008年09月29日 17:30:14 +0000 (2008年9月29日) Log Message: ----------- fix typo Modified Paths: -------------- trunk/toolkits/basemap/examples/warpimage.py Modified: trunk/toolkits/basemap/examples/warpimage.py =================================================================== --- trunk/toolkits/basemap/examples/warpimage.py 2008年09月29日 07:06:28 UTC (rev 6133) +++ trunk/toolkits/basemap/examples/warpimage.py 2008年09月29日 17:30:14 UTC (rev 6134) @@ -30,7 +30,7 @@ # draw lat/lon grid lines every 30 degrees. m.drawmeridians(np.arange(0,360,60),color='0.5') m.drawparallels(np.arange(-90,90,30),color='0.5') -plt.title("Blue Marble image warped from 'cyl' to 'robinso' projection",fontsize=12) +plt.title("Blue Marble image warped from 'cyl' to 'robinson' projection",fontsize=12) print 'warp to robinson map ...' # create new figure This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 6133 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6133&view=rev Author: efiring Date: 2008年09月29日 07:06:28 +0000 (2008年9月29日) Log Message: ----------- Add dpi kwarg and docstring to Text.get_window_extent() Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/text.py Modified: trunk/matplotlib/lib/matplotlib/text.py =================================================================== --- trunk/matplotlib/lib/matplotlib/text.py 2008年09月28日 22:05:23 UTC (rev 6132) +++ trunk/matplotlib/lib/matplotlib/text.py 2008年09月29日 07:06:28 UTC (rev 6133) @@ -166,7 +166,7 @@ self._rotation = rotation self._fontproperties = fontproperties self._bbox = None - self._bbox_patch = None # a FanceBboxPatch instance + self._bbox_patch = None # a FancyBboxPatch instance self._renderer = None if linespacing is None: linespacing = 1.2 # Maybe use rcParam later. @@ -356,7 +356,7 @@ def get_bbox_patch(self): """ - Retrun the bbox Patch object. Returns None if the the + Return the bbox Patch object. Returns None if the the FancyBboxPatch is not made. """ return self._bbox_patch @@ -519,9 +519,32 @@ "Return the vertical alignment as string" return self._verticalalignment - def get_window_extent(self, renderer=None): + def get_window_extent(self, renderer=None, dpi=None): + ''' + Return a Bbox bounding the text, in display units (dots). + + In addition to being used internally, + this is useful for specifying clickable regions in + a png file on a web page. + + *renderer* defaults to the _renderer attribute of the + text object. This is not assigned until the first execution + of the draw() method, so you must use this kwarg if you + want to call get_window_extent() prior to the first draw(). + For getting web page regions, it is simpler to call the + method after saving the figure. + + *dpi* defaults to self.figure.dpi; the renderer dpi is + irrelevant. For the web application, if figure.dpi is not + the value used when saving the figure, then the value that + was used must be specified as the *dpi* argument. + + ''' #return _unit_box if not self.get_visible(): return Bbox.unit() + if dpi is not None: + dpi_orig = self.figure.dpi + self.figure.dpi = dpi if self._text == '': tx, ty = self._get_xy_display() return Bbox.from_bounds(tx,ty,0,0) @@ -531,11 +554,12 @@ if self._renderer is None: raise RuntimeError('Cannot get window extent w/o renderer') - angle = self.get_rotation() bbox, info = self._get_layout(self._renderer) x, y = self.get_position() x, y = self.get_transform().transform_point((x, y)) bbox = bbox.translated(x, y) + if dpi is not None: + self.figure.dpi = dpi_orig return bbox def set_backgroundcolor(self, color): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 6132 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6132&view=rev Author: efiring Date: 2008年09月28日 22:05:23 +0000 (2008年9月28日) Log Message: ----------- Fix mri_with_eeg.py; it was not rescaling or printing correctly. Modified Paths: -------------- trunk/matplotlib/examples/pylab_examples/mri_with_eeg.py Modified: trunk/matplotlib/examples/pylab_examples/mri_with_eeg.py =================================================================== --- trunk/matplotlib/examples/pylab_examples/mri_with_eeg.py 2008年09月28日 13:32:55 UTC (rev 6131) +++ trunk/matplotlib/examples/pylab_examples/mri_with_eeg.py 2008年09月28日 22:05:23 UTC (rev 6132) @@ -4,16 +4,18 @@ faster* """ from __future__ import division -from pylab import * -from matplotlib.lines import Line2D -from matplotlib.transforms import Bbox, BboxTransform, BboxTransformTo, Affine2D +import numpy as np + +from matplotlib.pyplot import * +from matplotlib.collections import LineCollection + # I use if 1 to break up the different regions of code visually if 1: # load the data # data are 256x256 16 bit integers dfile = '../data/s1045.ima' - im = fromstring(file(dfile, 'rb').read(), uint16).astype(float) + im = np.fromstring(file(dfile, 'rb').read(), np.uint16).astype(float) im.shape = 256, 256 if 1: # plot the MRI in pcolor @@ -23,8 +25,8 @@ if 1: # plot the histogram of MRI intensity subplot(222) - im = ravel(im) - im = ravel(take(im, nonzero(im))) # ignore the background + im = np.ravel(im) + im = im[np.nonzero(im)] # ignore the background im = im/(2.0**15) # normalize hist(im, 100) xticks([-1, -.5, 0, .5, 1]) @@ -36,52 +38,38 @@ # load the data numSamples, numRows = 800,4 - data = fromstring(file('../data/eeg.dat', 'rb').read(), float) + data = np.fromstring(file('../data/eeg.dat', 'rb').read(), float) data.shape = numSamples, numRows - t = arange(numSamples)/float(numSamples)*10.0 + t = 10.0 * np.arange(numSamples, dtype=float)/numSamples ticklocs = [] ax = subplot(212) xlim(0,10) - xticks(arange(10)) + xticks(np.arange(10)) + dmin = data.min() + dmax = data.max() + dr = (dmax - dmin)*0.7 # Crowd them a bit. + y0 = dmin + y1 = (numRows-1) * dr + dmax + ylim(y0, y1) - boxin = Bbox.from_extents(ax.viewLim.x0, -20, ax.viewLim.x1, 20) - - height = ax.bbox.height - boxout = Bbox.from_extents(ax.bbox.x0, -1.0 * height, - ax.bbox.x1, 1.0 * height) - - transOffset = BboxTransformTo( - Bbox.from_extents(0.0, ax.bbox.y0, 1.0, ax.bbox.y1)) - - + segs = [] for i in range(numRows): - # effectively a copy of transData - trans = BboxTransform(boxin, boxout) - offset = (i+1)/(numRows+1) + segs.append(np.hstack((t[:,np.newaxis], data[:,i,np.newaxis]))) + ticklocs.append(i*dr) - trans += Affine2D().translate(*transOffset.transform_point((0, offset))) + offsets = np.zeros((numRows,2), dtype=float) + offsets[:,1] = ticklocs - thisLine = Line2D( - t, data[:,i]-data[0,i], - ) + lines = LineCollection(segs, offsets=offsets, + transOffset=None, + ) - thisLine.set_transform(trans) + ax.add_collection(lines) - ax.add_line(thisLine) - ticklocs.append(offset) - - setp(gca(), 'yticklabels', ['PG3', 'PG5', 'PG7', 'PG9']) - # set the yticks to use axes coords on the y axis ax.set_yticks(ticklocs) - for tick in ax.yaxis.get_major_ticks(): - tick.label1.set_transform(ax.transAxes) - tick.label2.set_transform(ax.transAxes) - tick.tick1line.set_transform(ax.transAxes) - tick.tick2line.set_transform(ax.transAxes) - tick.gridline.set_transform(ax.transAxes) + ax.set_yticklabels(['PG3', 'PG5', 'PG7', 'PG9']) - xlabel('time (s)') show() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 6131 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6131&view=rev Author: jswhit Date: 2008年09月28日 13:32:55 +0000 (2008年9月28日) Log Message: ----------- remove debug statements Modified Paths: -------------- trunk/toolkits/basemap/examples/warpimage.py Modified: trunk/toolkits/basemap/examples/warpimage.py =================================================================== --- trunk/toolkits/basemap/examples/warpimage.py 2008年09月28日 13:29:21 UTC (rev 6130) +++ trunk/toolkits/basemap/examples/warpimage.py 2008年09月28日 13:32:55 UTC (rev 6131) @@ -60,8 +60,6 @@ m.drawparallels(np.arange(-90,90,30),labels=[1,0,0,0],color='0.5') plt.title("Blue Marble image - non-native 'cyl' projection",fontsize=12) print 'plot non-native cylindrical map (warping needed) ...' -plt.show() -raise SystemExit # create new figure fig=plt.figure() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 6130 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6130&view=rev Author: jswhit Date: 2008年09月28日 13:29:21 +0000 (2008年9月28日) Log Message: ----------- another fix for warpimage and 'cyl' 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年09月28日 13:26:18 UTC (rev 6129) +++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2008年09月28日 13:29:21 UTC (rev 6130) @@ -3194,7 +3194,8 @@ # bmproj is True if map projection region is same as # image region. bmproj = self.projection == 'cyl' and \ - self.llcrnrlon == -180 and self.urcrnrlon == 180 + self.llcrnrlon == -180 and self.urcrnrlon == 180 and \ + self.llcrnrlat == -90 and self.urcrnrlat == 90 # read in jpeg image to rgba array of normalized floats. if not hasattr(self,'_bm_rgba') or newfile: pilImage = Image.open(self._bm_file) @@ -3216,7 +3217,7 @@ for k in range(3): tmp[:,:,k] = self._bm_rgba self._bm_rgba = tmp - if cylproj: + if cylproj and not bmproj: # stack grids side-by-side (in longitiudinal direction), so # any range of longitudes may be plotted on a world map. self._bm_lons = \ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 6129 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6129&view=rev Author: jswhit Date: 2008年09月28日 13:26:18 +0000 (2008年9月28日) Log Message: ----------- fix cyl example. Modified Paths: -------------- trunk/toolkits/basemap/examples/warpimage.py Modified: trunk/toolkits/basemap/examples/warpimage.py =================================================================== --- trunk/toolkits/basemap/examples/warpimage.py 2008年09月28日 03:07:04 UTC (rev 6128) +++ trunk/toolkits/basemap/examples/warpimage.py 2008年09月28日 13:26:18 UTC (rev 6129) @@ -56,10 +56,12 @@ # draw coastlines. m.drawcoastlines(linewidth=0.5,color='0.5') # draw lat/lon grid lines. -m.drawmeridians(np.arange(-180,180,60),labels=[0,0,0,1],color='0.5') +m.drawmeridians(np.arange(0,360,60),labels=[0,0,0,1],color='0.5') m.drawparallels(np.arange(-90,90,30),labels=[1,0,0,0],color='0.5') plt.title("Blue Marble image - non-native 'cyl' projection",fontsize=12) print 'plot non-native cylindrical map (warping needed) ...' +plt.show() +raise SystemExit # create new figure fig=plt.figure() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 6128 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6128&view=rev Author: efiring Date: 2008年09月28日 03:07:04 +0000 (2008年9月28日) Log Message: ----------- fixed cbook.flatten so its docstring example works Previously, flatten(('a','b')) triggered infinite recursion. Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/cbook.py Modified: trunk/matplotlib/lib/matplotlib/cbook.py =================================================================== --- trunk/matplotlib/lib/matplotlib/cbook.py 2008年09月28日 00:44:08 UTC (rev 6127) +++ trunk/matplotlib/lib/matplotlib/cbook.py 2008年09月28日 03:07:04 UTC (rev 6128) @@ -318,7 +318,10 @@ return fh, opened return fh -def flatten(seq, scalarp=is_scalar): +def is_scalar_or_string(val): + return is_string_like(val) or not iterable(val) + +def flatten(seq, scalarp=is_scalar_or_string): """ this generator flattens nested containers such as This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 6127 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6127&view=rev Author: efiring Date: 2008年09月28日 00:44:08 +0000 (2008年9月28日) Log Message: ----------- Enhancement to Axes.spy, and bugfixes: figlegend was not plotting markers; plot could not handle empty input arrays. Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/lib/matplotlib/axes.py trunk/matplotlib/lib/matplotlib/legend.py trunk/matplotlib/lib/matplotlib/lines.py trunk/matplotlib/lib/matplotlib/patches.py trunk/matplotlib/lib/matplotlib/transforms.py Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2008年09月28日 00:34:36 UTC (rev 6126) +++ trunk/matplotlib/CHANGELOG 2008年09月28日 00:44:08 UTC (rev 6127) @@ -1,3 +1,7 @@ +2008年09月27日 Allow spy to ignore zero values in sparse arrays, based + on patch by Tony Yu. Also fixed plot to handle empty + data arrays, and fixed handling of markers in figlegend. - EF + 2008年09月24日 Introduce drawstyles for lines. Transparently split linestyles like 'steps--' into drawstyle 'steps' and linestyle '--'. Legends always use drawstyle 'default'. - MM @@ -81,7 +85,7 @@ 2008年07月24日 Rewrite of a significant portion of the clabel code (class ContourLabeler) to improve inlining. - DMK - + 2008年07月22日 Added Barbs polygon collection (similar to Quiver) for plotting wind barbs. Added corresponding helpers to Axes and pyplot as well. (examples/pylab_examples/barb_demo.py shows it off.) - RMM Modified: trunk/matplotlib/lib/matplotlib/axes.py =================================================================== --- trunk/matplotlib/lib/matplotlib/axes.py 2008年09月28日 00:34:36 UTC (rev 6126) +++ trunk/matplotlib/lib/matplotlib/axes.py 2008年09月28日 00:44:08 UTC (rev 6127) @@ -309,7 +309,8 @@ x = self.axes.convert_xunits(x) y = self.axes.convert_yunits(y) facecolor = self._get_next_cycle_color() - seg = mpatches.Polygon(zip(x, y), + seg = mpatches.Polygon(np.hstack( + (x[:,np.newaxis],y[:,np.newaxis])), facecolor = facecolor, fill=True, closed=closed @@ -355,7 +356,8 @@ facecolor = color x = self.axes.convert_xunits(x) y = self.axes.convert_yunits(y) - seg = mpatches.Polygon(zip(x, y), + seg = mpatches.Polygon(np.hstack( + (x[:,np.newaxis],y[:,np.newaxis])), facecolor = facecolor, fill=True, closed=closed @@ -1282,9 +1284,10 @@ line._remove_method = lambda h: self.lines.remove(h) def _update_line_limits(self, line): - self.dataLim.update_from_path(line.get_path(), - self.ignore_existing_data_limits) - self.ignore_existing_data_limits = False + p = line.get_path() + if p.vertices.size > 0: + self.dataLim.update_from_path(p, self.ignore_existing_data_limits) + self.ignore_existing_data_limits = False def add_patch(self, p): """ @@ -1300,21 +1303,26 @@ self.patches.append(p) p._remove_method = lambda h: self.patches.remove(h) - def _update_patch_limits(self, p): + def _update_patch_limits(self, patch): 'update the data limits for patch *p*' # hist can add zero height Rectangles, which is useful to keep # the bins, counts and patches lined up, but it throws off log # scaling. We'll ignore rects with zero height or width in # the auto-scaling - if isinstance(p, mpatches.Rectangle) and (p.get_width()==0. or p.get_height()==0.): + + if (isinstance(patch, mpatches.Rectangle) and + (patch.get_width()==0 or patch.get_height()==0)): return - vertices = p.get_patch_transform().transform(p.get_path().vertices) - if p.get_data_transform() != self.transData: - transform = p.get_data_transform() + self.transData.inverted() - xys = transform.transform(vertices) - # Something is wrong--xys is never used. - self.update_datalim(vertices) + vertices = patch.get_path().vertices + if vertices.size > 0: + xys = patch.get_patch_transform().transform(vertices) + if patch.get_data_transform() != self.transData: + transform = (patch.get_data_transform() + + self.transData.inverted()) + xys = transform.transform(xys) + self.update_datalim(xys) + def add_table(self, tab): ''' Add a :class:`~matplotlib.tables.Table` instance to the @@ -6645,7 +6653,7 @@ return Pxx, freqs, bins, im def spy(self, Z, precision=None, marker=None, markersize=None, - aspect='equal', **kwargs): + aspect='equal', **kwargs): """ call signature:: @@ -6657,6 +6665,10 @@ If *precision* is *None*, any non-zero value will be plotted; else, values of :math:`|Z| > precision` will be plotted. + For :class:`scipy.sparse.spmatrix` instances, there is a + special case: if *precision* is 0, any value present in + the array will be plotted, even if it is identically zero. + The array will be plotted as it would be printed, with the first index (row) increasing down and the second index (column) increasing to the right. @@ -6707,9 +6719,9 @@ * ',' pixel """ + if marker is None and markersize is None and hasattr(Z, 'tocoo'): + marker = 's' if marker is None and markersize is None: - if hasattr(Z, 'tocoo'): - raise TypeError, "Image mode does not support scipy.sparse arrays" Z = np.asarray(Z) if precision is None: mask = Z!=0. else: mask = np.absolute(Z)>precision @@ -6723,23 +6735,33 @@ else: if hasattr(Z, 'tocoo'): c = Z.tocoo() - y = c.row - x = c.col - z = c.data + if precision == 0: + y = c.row + x = c.col + else: + if precision is None: + nonzero = c.data != 0. + else: + nonzero = np.absolute(c.data) > precision + y = c.row[nonzero] + x = c.col[nonzero] else: Z = np.asarray(Z) - if precision is None: mask = Z!=0. - else: mask = np.absolute(Z)>precision - y,x,z = mlab.get_xyz_where(mask, mask) + if precision is None: + nonzero = Z!=0. + else: + nonzero = np.absolute(Z)>precision + y, x = np.nonzero(nonzero) if marker is None: marker = 's' if markersize is None: markersize = 10 - lines = self.plot(x, y, linestyle='None', + marks = mlines.Line2D(x, y, linestyle='None', marker=marker, markersize=markersize, **kwargs) + self.add_line(marks) nr, nc = Z.shape self.set_xlim(xmin=-0.5, xmax=nc-0.5) self.set_ylim(ymin=nr-0.5, ymax=-0.5) self.set_aspect(aspect) - ret = lines + ret = marks self.title.set_y(1.05) self.xaxis.tick_top() self.xaxis.set_ticks_position('both') Modified: trunk/matplotlib/lib/matplotlib/legend.py =================================================================== --- trunk/matplotlib/lib/matplotlib/legend.py 2008年09月28日 00:34:36 UTC (rev 6126) +++ trunk/matplotlib/lib/matplotlib/legend.py 2008年09月28日 00:44:08 UTC (rev 6127) @@ -264,13 +264,15 @@ legline.set_clip_box(None) legline.set_clip_path(None) legline.set_drawstyle('default') + legline.set_marker('None') ret.append(legline) - legline.set_marker('None') legline_marker = Line2D(xdata_marker, ydata[:len(xdata_marker)]) legline_marker.update_from(handle) + self._set_artist_props(legline_marker) + legline_marker.set_clip_box(None) + legline_marker.set_clip_path(None) legline_marker.set_linestyle('None') - self._set_artist_props(legline_marker) # we don't want to add this to the return list because # the texts and handles are assumed to be in one-to-one # correpondence. Modified: trunk/matplotlib/lib/matplotlib/lines.py =================================================================== --- trunk/matplotlib/lib/matplotlib/lines.py 2008年09月28日 00:34:36 UTC (rev 6126) +++ trunk/matplotlib/lib/matplotlib/lines.py 2008年09月28日 00:44:08 UTC (rev 6127) @@ -81,14 +81,14 @@ ' ' : '_draw_nothing', '' : '_draw_nothing', } - + _drawStyles_l = { 'default' : '_draw_lines', 'steps-mid' : '_draw_steps_mid', 'steps-pre' : '_draw_steps_pre', 'steps-post' : '_draw_steps_post', } - + _drawStyles_s = { 'steps' : '_draw_steps_pre', } Modified: trunk/matplotlib/lib/matplotlib/patches.py =================================================================== --- trunk/matplotlib/lib/matplotlib/patches.py 2008年09月28日 00:34:36 UTC (rev 6126) +++ trunk/matplotlib/lib/matplotlib/patches.py 2008年09月28日 00:44:08 UTC (rev 6127) @@ -408,7 +408,7 @@ return self._rect_transform def contains(self, mouseevent): - # special case the degernate rectangle + # special case the degenerate rectangle if self._width==0 or self._height==0: return False, {} Modified: trunk/matplotlib/lib/matplotlib/transforms.py =================================================================== --- trunk/matplotlib/lib/matplotlib/transforms.py 2008年09月28日 00:34:36 UTC (rev 6126) +++ trunk/matplotlib/lib/matplotlib/transforms.py 2008年09月28日 00:44:08 UTC (rev 6127) @@ -801,6 +801,9 @@ if ignore is None: ignore = self._ignore + if path.vertices.size == 0: + return + points, minpos, changed = update_path_extents( path, None, self._points, self._minpos, ignore) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 6126 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6126&view=rev Author: jswhit Date: 2008年09月28日 00:34:36 +0000 (2008年9月28日) Log Message: ----------- added robinson and cyl tests Modified Paths: -------------- trunk/toolkits/basemap/examples/warpimage.py Modified: trunk/toolkits/basemap/examples/warpimage.py =================================================================== --- trunk/toolkits/basemap/examples/warpimage.py 2008年09月27日 20:33:21 UTC (rev 6125) +++ trunk/toolkits/basemap/examples/warpimage.py 2008年09月28日 00:34:36 UTC (rev 6126) @@ -20,9 +20,18 @@ plt.title("Lights at Night image warped from 'cyl' to 'ortho' projection",fontsize=12) print 'warp to orthographic map ...' -# redisplay (same image specified) should be fast since data is cached. -fig = plt.figure() -m.warpimage(image='earth_lights_lrg.jpg') +# create new figure +fig=plt.figure() +# define orthographic projection centered on North America. +m = Basemap(projection='robin',lon_0=-100,resolution='l') +m.bluemarble() +# draw coastlines. +m.drawcoastlines(linewidth=0.5,color='0.5') +# draw lat/lon grid lines every 30 degrees. +m.drawmeridians(np.arange(0,360,60),color='0.5') +m.drawparallels(np.arange(-90,90,30),color='0.5') +plt.title("Blue Marble image warped from 'cyl' to 'robinso' projection",fontsize=12) +print 'warp to robinson map ...' # create new figure fig=plt.figure() @@ -36,10 +45,24 @@ m.drawmeridians(np.arange(-180,180,60),labels=[0,0,0,1],color='0.5') m.drawparallels(np.arange(-90,90,30),labels=[1,0,0,0],color='0.5') plt.title("Blue Marble image - native 'cyl' projection",fontsize=12) -print 'plot cylindrical map (no warping needed) ...' +print 'plot native cylindrical map (no warping needed) ...' # create new figure fig=plt.figure() +# define cylindrical equidistant projection. +m = Basemap(projection='cyl',llcrnrlon=0,llcrnrlat=-60,urcrnrlon=360,urcrnrlat=60,resolution='l') +# plot (unwarped) rgba image. +im = m.bluemarble() +# draw coastlines. +m.drawcoastlines(linewidth=0.5,color='0.5') +# draw lat/lon grid lines. +m.drawmeridians(np.arange(-180,180,60),labels=[0,0,0,1],color='0.5') +m.drawparallels(np.arange(-90,90,30),labels=[1,0,0,0],color='0.5') +plt.title("Blue Marble image - non-native 'cyl' projection",fontsize=12) +print 'plot non-native cylindrical map (warping needed) ...' + +# create new figure +fig=plt.figure() # define orthographic projection centered on Europe. m = Basemap(projection='ortho',lat_0=40,lon_0=40,resolution='l') # plot a gray-scale image specified from a URL. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 6125 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6125&view=rev Author: jswhit Date: 2008年09月27日 20:33:21 +0000 (2008年9月27日) Log Message: ----------- more fixes for warpimage and cylindrical projections. 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年09月27日 17:36:35 UTC (rev 6124) +++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2008年09月27日 20:33:21 UTC (rev 6125) @@ -3191,10 +3191,24 @@ self._bm_file, headers = urlretrieve(file) else: self._bm_file = file + # bmproj is True if map projection region is same as + # image region. + bmproj = self.projection == 'cyl' and \ + self.llcrnrlon == -180 and self.urcrnrlon == 180 # read in jpeg image to rgba array of normalized floats. if not hasattr(self,'_bm_rgba') or newfile: pilImage = Image.open(self._bm_file) self._bm_rgba = pil_to_array(pilImage) + # define lat/lon grid that image spans. + nlons = self._bm_rgba.shape[1]; nlats = self._bm_rgba.shape[0] + delta = 360./float(nlons) + self._bm_lons = np.arange(-180.+0.5*delta,180.,delta) + self._bm_lats = np.arange(-90.+0.5*delta,90.,delta) + # is it a cylindrical projection whose limits lie + # outside the limits of the image? + cylproj = self.projection in ['mill','cyl','merc'] and \ + (self.urcrnrlon > self._bm_lons[-1] or \ + self.llcrnrlon < self._bm_lons[0]) # if pil_to_array returns a 2D array, it's a grayscale image. # create an RGB image, with R==G==B. if self._bm_rgba.ndim == 2: @@ -3202,16 +3216,15 @@ for k in range(3): tmp[:,:,k] = self._bm_rgba self._bm_rgba = tmp + if cylproj: + # stack grids side-by-side (in longitiudinal direction), so + # any range of longitudes may be plotted on a world map. + self._bm_lons = \ + np.concatenate((self._bm_lons,self._bm_lons+360),1) + self._bm_rgba = \ + np.concatenate((self._bm_rgba,self._bm_rgba),1) # convert to normalized floats. self._bm_rgba = self._bm_rgba.astype(np.float32)/255. - # define lat/lon grid that image spans. - nlons = self._bm_rgba.shape[1]; nlats = self._bm_rgba.shape[0] - delta = 360./float(nlons) - self._bm_lons = np.arange(-180.+0.5*delta,180.,delta) - self._bm_lats = np.arange(-90.+0.5*delta,90.,delta) - - bmproj = self.projection == 'cyl' and \ - self.llcrnrlon == -180 and self.urcrnrlon == 180 if not bmproj: if newfile or not hasattr(self,'_bm_rgba_warped'): # transform to nx x ny regularly spaced native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 6124 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6124&view=rev Author: jswhit Date: 2008年09月27日 17:36:35 +0000 (2008年9月27日) Log Message: ----------- fix warpimage/bluemarble methods for 'cyl','robin','moll' and 'sinu' projections. Modified Paths: -------------- trunk/toolkits/basemap/Changelog trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py Modified: trunk/toolkits/basemap/Changelog =================================================================== --- trunk/toolkits/basemap/Changelog 2008年09月26日 21:52:34 UTC (rev 6123) +++ trunk/toolkits/basemap/Changelog 2008年09月27日 17:36:35 UTC (rev 6124) @@ -1,4 +1,6 @@ version 0.99.2 (not yet released) + * fix warpimage and bluemarble methods for projection = 'cyl', + 'robin', 'moll' and 'sinu'. * bugfix patch for rotate_vector from David Huard. David also contributed the beginnings of a test suite. * _geoslib.so now installed in mpl_toolkits.basemap. Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py =================================================================== --- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2008年09月26日 21:52:34 UTC (rev 6123) +++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2008年09月27日 17:36:35 UTC (rev 6124) @@ -3210,15 +3210,22 @@ self._bm_lons = np.arange(-180.+0.5*delta,180.,delta) self._bm_lats = np.arange(-90.+0.5*delta,90.,delta) - if self.projection != 'cyl': + bmproj = self.projection == 'cyl' and \ + self.llcrnrlon == -180 and self.urcrnrlon == 180 + if not bmproj: if newfile or not hasattr(self,'_bm_rgba_warped'): # transform to nx x ny regularly spaced native # projection grid. # nx and ny chosen to have roughly the # same horizontal res as original image. - dx = 2.*np.pi*self.rmajor/float(nlons) - nx = int((self.xmax-self.xmin)/dx)+1 - ny = int((self.ymax-self.ymin)/dx)+1 + if self.projection != 'cyl': + dx = 2.*np.pi*self.rmajor/float(nlons) + nx = int((self.xmax-self.xmin)/dx)+1 + ny = int((self.ymax-self.ymin)/dx)+1 + else: + dx = 360./float(nlons) + nx = int((self.urcrnrlon-self.llcrnrlon)/dx)+1 + ny = int((self.urcrnrlat-self.llcrnrlat)/dx)+1 self._bm_rgba_warped = np.ones((ny,nx,4),np.float64) # interpolate rgba values from geographic coords (proj='cyl') # to map projection coords. @@ -3231,7 +3238,7 @@ # for ortho,geos mask pixels outside projection limb. if self.projection in ['geos','ortho']: lonsr,latsr = self(x,y,inverse=True) - mask = ma.zeros((nx,ny,4),np.int8) + mask = ma.zeros((ny,nx,4),np.int8) mask[:,:,0] = np.logical_or(lonsr>1.e20,latsr>1.e30) for k in range(1,4): mask[:,:,k] = mask[:,:,0] @@ -3239,6 +3246,28 @@ ma.masked_array(self._bm_rgba_warped,mask=mask) # make points outside projection limb transparent. self._bm_rgba_warped = self._bm_rgba_warped.filled(0.) + # treat mollweide, robinson and sinusoidal. + elif self.projection in ['moll','robin','sinu']: + lonsr,latsr = self(x,y,inverse=True) + mask = ma.zeros((ny,nx,4),np.int8) + lon_0 = self.projparams['lon_0'] + lonright = lon_0+180. + lonleft = lon_0-180. + x1 = np.array(ny*[0.5*(self.xmax + self.xmin)],np.float) + y1 = np.linspace(self.ymin, self.ymax, ny) + lons1, lats1 = self(x1,y1,inverse=True) + lats1 = np.where(lats1 < -89.999999, -89.999999, lats1) + lats1 = np.where(lats1 > 89.999999, 89.999999, lats1) + for j,lat in enumerate(lats1): + xmax,ymax = self(lonright,lat) + xmin,ymin = self(lonleft,lat) + mask[j,:,0] = np.logical_or(x[j,:]>xmax,x[j,:]<xmin) + for k in range(1,4): + mask[:,:,k] = mask[:,:,0] + self._bm_rgba_warped = \ + ma.masked_array(self._bm_rgba_warped,mask=mask) + # make points outside projection limb transparent. + self._bm_rgba_warped = self._bm_rgba_warped.filled(0.) # plot warped rgba image. im = self.imshow(self._bm_rgba_warped,ax=ax) else: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 6123 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6123&view=rev Author: efiring Date: 2008年09月26日 21:52:34 +0000 (2008年9月26日) Log Message: ----------- fixed bug in PrintoutWX--thanks to Ziwen Fu Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/backends/backend_wx.py Modified: trunk/matplotlib/lib/matplotlib/backends/backend_wx.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_wx.py 2008年09月25日 17:16:30 UTC (rev 6122) +++ trunk/matplotlib/lib/matplotlib/backends/backend_wx.py 2008年09月26日 21:52:34 UTC (rev 6123) @@ -2109,7 +2109,7 @@ # restore original figure resolution self.canvas.figure.set_facecolor(bgcolor) - self.canvas.figure.dpi.set(fig_dpi) + self.canvas.figure.dpi = fig_dpi self.canvas.draw() return True #> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 6122 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6122&view=rev Author: jouni Date: 2008年09月25日 17:16:30 +0000 (2008年9月25日) Log Message: ----------- Import quad2cubic from mlab, not the nonexistent numerical_methods Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py trunk/matplotlib/lib/matplotlib/backends/backend_ps.py Modified: trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py 2008年09月25日 13:46:00 UTC (rev 6121) +++ trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py 2008年09月25日 17:16:30 UTC (rev 6122) @@ -27,7 +27,7 @@ from matplotlib.backends.backend_mixed import MixedModeRenderer from matplotlib.cbook import Bunch, is_string_like, reverse_dict, \ get_realpath_and_stat, is_writable_file_like, maxdict -from matplotlib.numerical_methods import quad2cubic +from matplotlib.mlab import quad2cubic from matplotlib.figure import Figure from matplotlib.font_manager import findfont, is_opentype_cff_font from matplotlib.afm import AFM Modified: trunk/matplotlib/lib/matplotlib/backends/backend_ps.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_ps.py 2008年09月25日 13:46:00 UTC (rev 6121) +++ trunk/matplotlib/lib/matplotlib/backends/backend_ps.py 2008年09月25日 17:16:30 UTC (rev 6122) @@ -21,7 +21,7 @@ from matplotlib.cbook import is_string_like, get_realpath_and_stat, \ is_writable_file_like, maxdict -from matplotlib.numerical_methods import quad2cubic +from matplotlib.mlab import quad2cubic from matplotlib.figure import Figure from matplotlib.font_manager import findfont, is_opentype_cff_font This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 6121 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6121&view=rev Author: mdboom Date: 2008年09月25日 13:46:00 +0000 (2008年9月25日) Log Message: ----------- Fix double rendering when saving PNGs with Agg backend. Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/backends/backend_agg.py Modified: trunk/matplotlib/lib/matplotlib/backends/backend_agg.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_agg.py 2008年09月24日 09:21:41 UTC (rev 6120) +++ trunk/matplotlib/lib/matplotlib/backends/backend_agg.py 2008年09月25日 13:46:00 UTC (rev 6121) @@ -308,8 +308,6 @@ renderer.dpi = self.figure.dpi if is_string_like(filename_or_obj): filename_or_obj = file(filename_or_obj, 'wb') - renderer = self.get_renderer() - x = renderer._renderer.buffer_rgba(0, 0) _png.write_png(renderer._renderer.buffer_rgba(0, 0), renderer.width, renderer.height, filename_or_obj, self.figure.dpi) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 6120 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6120&view=rev Author: mmetz_bn Date: 2008年09月24日 09:21:41 +0000 (2008年9月24日) Log Message: ----------- minor typo Modified Paths: -------------- trunk/matplotlib/doc/users/pyplot_tutorial.rst Modified: trunk/matplotlib/doc/users/pyplot_tutorial.rst =================================================================== --- trunk/matplotlib/doc/users/pyplot_tutorial.rst 2008年09月24日 08:58:16 UTC (rev 6119) +++ trunk/matplotlib/doc/users/pyplot_tutorial.rst 2008年09月24日 09:21:41 UTC (rev 6120) @@ -71,7 +71,7 @@ * Use the setter methods of the ``Line2D`` instance. ``plot`` returns a list of lines; eg ``line1, line2 = plot(x1,y1,x2,x2)``. Below I have only - one line so it is a list of7 length 1. I use tuple unpacking in the + one line so it is a list of length 1. I use tuple unpacking in the ``line, = plot(x, y, 'o')`` to get the first element of the list:: line, = plt.plot(x, y, 'o') @@ -134,9 +134,9 @@ .. sourcecode:: ipython - In [69]: lines = plot([1,2,3]) + In [69]: lines = plt.plot([1,2,3]) - In [70]: setp(lines) + In [70]: plt.setp(lines) alpha: float animated: [True | False] antialiased or aa: [True | False] This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 6119 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6119&view=rev Author: mmetz_bn Date: 2008年09月24日 08:58:16 +0000 (2008年9月24日) Log Message: ----------- Separate drawstyles and linestyles for lines Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/lib/matplotlib/legend.py trunk/matplotlib/lib/matplotlib/lines.py Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2008年09月23日 18:59:54 UTC (rev 6118) +++ trunk/matplotlib/CHANGELOG 2008年09月24日 08:58:16 UTC (rev 6119) @@ -1,3 +1,7 @@ +2008年09月24日 Introduce drawstyles for lines. Transparently split linestyles + like 'steps--' into drawstyle 'steps' and linestyle '--'. + Legends always use drawstyle 'default'. - MM + 2008年09月18日 Fixed quiver and quiverkey bugs (failure to scale properly when resizing) and added additional methods for determining the arrow angles - EF Modified: trunk/matplotlib/lib/matplotlib/legend.py =================================================================== --- trunk/matplotlib/lib/matplotlib/legend.py 2008年09月23日 18:59:54 UTC (rev 6118) +++ trunk/matplotlib/lib/matplotlib/legend.py 2008年09月24日 08:58:16 UTC (rev 6119) @@ -263,6 +263,7 @@ self._set_artist_props(legline) # after update legline.set_clip_box(None) legline.set_clip_path(None) + legline.set_drawstyle('default') ret.append(legline) legline.set_marker('None') Modified: trunk/matplotlib/lib/matplotlib/lines.py =================================================================== --- trunk/matplotlib/lib/matplotlib/lines.py 2008年09月23日 18:59:54 UTC (rev 6118) +++ trunk/matplotlib/lib/matplotlib/lines.py 2008年09月24日 08:58:16 UTC (rev 6119) @@ -11,7 +11,8 @@ from matplotlib import verbose import artist from artist import Artist -from cbook import iterable, is_string_like, is_numlike, ls_mapper, dedent +from cbook import iterable, is_string_like, is_numlike, ls_mapper, dedent,\ +flatten from colors import colorConverter from path import Path from transforms import Affine2D, Bbox, TransformedPath, IdentityTransform @@ -76,14 +77,24 @@ '--' : '_draw_dashed', '-.' : '_draw_dash_dot', ':' : '_draw_dotted', - 'steps' : '_draw_steps_pre', - 'steps-mid' : '_draw_steps_mid', - 'steps-pre' : '_draw_steps_pre', - 'steps-post' : '_draw_steps_post', 'None' : '_draw_nothing', ' ' : '_draw_nothing', '' : '_draw_nothing', } + + _drawStyles_l = { + 'default' : '_draw_lines', + 'steps-mid' : '_draw_steps_mid', + 'steps-pre' : '_draw_steps_pre', + 'steps-post' : '_draw_steps_post', + } + + _drawStyles_s = { + 'steps' : '_draw_steps_pre', + } + drawStyles = {} + drawStyles.update(_drawStyles_l) + drawStyles.update(_drawStyles_s) markers = _markers = { # hidden names deprecated '.' : '_draw_point', @@ -155,6 +166,7 @@ dash_joinstyle = None, solid_joinstyle = None, pickradius = 5, + drawstyle = None, **kwargs ): """ @@ -185,6 +197,8 @@ if solid_capstyle is None : solid_capstyle=rcParams['lines.solid_capstyle'] if solid_joinstyle is None : solid_joinstyle=rcParams['lines.solid_joinstyle'] + if drawstyle is None : drawstyle='default' + self.set_dash_capstyle(dash_capstyle) self.set_dash_joinstyle(dash_joinstyle) self.set_solid_capstyle(solid_capstyle) @@ -192,6 +206,7 @@ self.set_linestyle(linestyle) + self.set_drawstyle(drawstyle) self.set_linewidth(linewidth) self.set_color(color) self.set_marker(marker) @@ -423,8 +438,10 @@ funcname = self._lineStyles.get(self._linestyle, '_draw_nothing') if funcname != '_draw_nothing': tpath, affine = self._transformed_path.get_transformed_path_and_affine() - lineFunc = getattr(self, funcname) - lineFunc(renderer, gc, tpath, affine.frozen()) + self._lineFunc = getattr(self, funcname) + funcname = self.drawStyles.get(self._drawstyle, '_draw_lines') + drawFunc = getattr(self, funcname) + drawFunc(renderer, gc, tpath, affine.frozen()) if self._marker is not None: gc = renderer.new_gc() @@ -442,6 +459,7 @@ def get_antialiased(self): return self._antialiased def get_color(self): return self._color + def get_drawstyle(self): return self._drawstyle def get_linestyle(self): return self._linestyle def get_linewidth(self): return self._linewidth @@ -543,6 +561,18 @@ """ self._color = color + def set_drawstyle(self, drawstyle): + """ + Set the drawstyle of the plot + + 'default' connects the points with lines. The steps variants + produce step-plots. 'steps' is equivalent to 'steps-pre' and + is maintained for backward-compatibility. + + ACCEPTS: [ 'default' | 'steps' | 'steps-pre' | 'steps-mid' | 'steps-post' ] + """ + self._drawstyle = drawstyle + def set_linewidth(self, w): """ Set the line width in points @@ -558,8 +588,20 @@ 'steps' is equivalent to 'steps-pre' and is maintained for backward-compatibility. - ACCEPTS: [ '-' | '--' | '-.' | ':' | 'steps' | 'steps-pre' | 'steps-mid' | 'steps-post' | 'None' | ' ' | '' ] + ACCEPTS: [ '-' | '--' | '-.' | ':' | 'None' | ' ' | '' ] and + any drawstyle in combination with a linestyle, e.g. 'steps--'. """ + + # handle long drawstyle names before short ones ! + for ds in flatten([k.keys() for k in (self._drawStyles_l, + self._drawStyles_s)], is_string_like): + if linestyle.startswith(ds): + self.set_drawstyle(ds) + if len(linestyle) > len(ds): + linestyle = linestyle[len(ds):] + else: + linestyle = '-' + if linestyle not in self._lineStyles: if ls_mapper.has_key(linestyle): linestyle = ls_mapper[linestyle] @@ -569,7 +611,6 @@ if linestyle in [' ','']: linestyle = 'None' self._linestyle = linestyle - self._lineFunc = self._lineStyles[linestyle] def set_marker(self, marker): """ @@ -660,15 +701,10 @@ self.set_linestyle('--') self._dashSeq = seq # TODO: offset ignored for now - def _draw_nothing(self, *args, **kwargs): - pass + def _draw_lines(self, renderer, gc, path, trans): + self._lineFunc(renderer, gc, path, trans) - def _draw_solid(self, renderer, gc, path, trans): - gc.set_linestyle('solid') - renderer.draw_path(gc, path, trans) - - def _draw_steps_pre(self, renderer, gc, path, trans): vertices = self._xy steps = ma.zeros((2*len(vertices)-1, 2), np.float_) @@ -678,9 +714,8 @@ path = Path(steps) path = path.transformed(self.get_transform()) - self._draw_solid(renderer, gc, path, IdentityTransform()) + self._lineFunc(renderer, gc, path, IdentityTransform()) - def _draw_steps_post(self, renderer, gc, path, trans): vertices = self._xy steps = ma.zeros((2*len(vertices)-1, 2), np.float_) @@ -690,9 +725,8 @@ path = Path(steps) path = path.transformed(self.get_transform()) - self._draw_solid(renderer, gc, path, IdentityTransform()) + self._lineFunc(renderer, gc, path, IdentityTransform()) - def _draw_steps_mid(self, renderer, gc, path, trans): vertices = self._xy steps = ma.zeros((2*len(vertices), 2), np.float_) @@ -705,9 +739,16 @@ path = Path(steps) path = path.transformed(self.get_transform()) - self._draw_solid(renderer, gc, path, IdentityTransform()) + self._lineFunc(renderer, gc, path, IdentityTransform()) + def _draw_nothing(self, *args, **kwargs): + pass + + def _draw_solid(self, renderer, gc, path, trans): + gc.set_linestyle('solid') + renderer.draw_path(gc, path, trans) + def _draw_dashed(self, renderer, gc, path, trans): gc.set_linestyle('dashed') if self._dashSeq is not None: @@ -990,6 +1031,7 @@ self._linestyle = other._linestyle self._marker = other._marker + self._drawstyle = other._drawstyle def _get_rgb_face(self): @@ -1239,6 +1281,7 @@ lineStyles = Line2D._lineStyles lineMarkers = Line2D._markers +drawStyles = Line2D.drawStyles artist.kwdocd['Line2D'] = artist.kwdoc(Line2D) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 6118 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6118&view=rev Author: jswhit Date: 2008年09月23日 18:59:54 +0000 (2008年9月23日) Log Message: ----------- more workarounds for geos library version 3 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年09月23日 18:25:27 UTC (rev 6117) +++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2008年09月23日 18:59:54 UTC (rev 6118) @@ -926,8 +926,12 @@ if not antart: b2[:,0] = b[:,0]-360 poly1 = Shape(b2) + if _geoslib.__geos_major_version__ > 2: + poly1 = poly1.simplify(1.e-10) b2[:,0] = b[:,0]+360 poly2 = Shape(b2) + if _geoslib.__geos_major_version__ > 2: + poly2 = poly2.simplify(1.e-10) polys = [poly1,poly,poly2] else: # Antartica already extends from -360 to +720. polys = [poly] This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 6117 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6117&view=rev Author: jdh2358 Date: 2008年09月23日 18:25:27 +0000 (2008年9月23日) Log Message: ----------- fixed numerical methods imports -> mlab Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/contour.py trunk/matplotlib/lib/matplotlib/pylab.py Modified: trunk/matplotlib/lib/matplotlib/contour.py =================================================================== --- trunk/matplotlib/lib/matplotlib/contour.py 2008年09月23日 18:22:54 UTC (rev 6116) +++ trunk/matplotlib/lib/matplotlib/contour.py 2008年09月23日 18:25:27 UTC (rev 6117) @@ -16,7 +16,7 @@ import matplotlib.font_manager as font_manager import matplotlib.text as text import matplotlib.cbook as cbook -import matplotlib.numerical_methods as numerical_methods +import matplotlib.mlab as mlab # Import needed for adding manual selection capability to clabel from matplotlib.blocking_input import BlockingContourLabeler @@ -335,7 +335,7 @@ not empty (lc defaults to the empty list if None). *spacing* is the space around the label in pixels to leave empty. - Do both of these tasks at once to avoid calling numerical_methods.path_length + Do both of these tasks at once to avoid calling mlab.path_length multiple times, which is relatively costly. The method used here involves calculating the path length @@ -349,7 +349,7 @@ hlw = lw/2.0 # Check if closed and, if so, rotate contour so label is at edge - closed = numerical_methods.is_closed_polygon(slc) + closed = mlab.is_closed_polygon(slc) if closed: slc = np.r_[ slc[ind:-1], slc[:ind+1] ] @@ -359,7 +359,7 @@ ind = 0 # Path length in pixel space - pl = numerical_methods.path_length(slc) + pl = mlab.path_length(slc) pl = pl-pl[ind] # Use linear interpolation to get points around label @@ -369,7 +369,7 @@ else: dp = np.zeros_like(xi) - ll = numerical_methods.less_simple_linear_interpolation( pl, slc, dp+xi, + ll = mlab.less_simple_linear_interpolation( pl, slc, dp+xi, extrap=True ) # get vector in pixel space coordinates from one point to other @@ -395,16 +395,16 @@ xi = dp + xi + np.array([-spacing,spacing]) # Get indices near points of interest - I = numerical_methods.less_simple_linear_interpolation( + I = mlab.less_simple_linear_interpolation( pl, np.arange(len(pl)), xi, extrap=False ) # If those indices aren't beyond contour edge, find x,y if (not np.isnan(I[0])) and int(I[0])<>I[0]: - xy1 = numerical_methods.less_simple_linear_interpolation( + xy1 = mlab.less_simple_linear_interpolation( pl, lc, [ xi[0] ] ) if (not np.isnan(I[1])) and int(I[1])<>I[1]: - xy2 = numerical_methods.less_simple_linear_interpolation( + xy2 = mlab.less_simple_linear_interpolation( pl, lc, [ xi[1] ] ) # Make integer @@ -472,7 +472,7 @@ # zero in print_label and locate_label. Other than these # functions, this is not necessary and should probably be # eventually removed. - if numerical_methods.is_closed_polygon( lc ): + if mlab.is_closed_polygon( lc ): slc = np.r_[ slc0, slc0[1:2,:] ] else: slc = slc0 @@ -1009,12 +1009,12 @@ *linestyles*: [None | 'solid' | 'dashed' | 'dashdot' | 'dotted' ] If *linestyles* is *None*, the 'solid' is used. - + *linestyles* can also be an iterable of the above strings specifying a set of linestyles to be used. If this iterable is shorter than the number of contour levels it will be repeated as necessary. - + If contour is using a monochrome colormap and the contour level is less than 0, then the linestyle specified in ``contour.negative_linestyle`` in ``matplotlibrc`` Modified: trunk/matplotlib/lib/matplotlib/pylab.py =================================================================== --- trunk/matplotlib/lib/matplotlib/pylab.py 2008年09月23日 18:22:54 UTC (rev 6116) +++ trunk/matplotlib/lib/matplotlib/pylab.py 2008年09月23日 18:25:27 UTC (rev 6117) @@ -227,7 +227,7 @@ diagonal_matrix, base_repr, binary_repr, log2, ispower2,\ bivariate_normal, load, save -from matplotlib.numerical_methods import stineman_interp, slopes, \ +from matplotlib.mlab import stineman_interp, slopes, \ stineman_interp, inside_poly, poly_below, poly_between, \ is_closed_polygon, path_length, distances_along_curve, vector_lengths This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 6116 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6116&view=rev Author: jdh2358 Date: 2008年09月23日 18:22:54 +0000 (2008年9月23日) Log Message: ----------- moved nemerical methods back to mlab pending more comprehensive reorg Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/mlab.py Removed Paths: ------------- trunk/matplotlib/lib/matplotlib/numerical_methods.py Modified: trunk/matplotlib/lib/matplotlib/mlab.py =================================================================== --- trunk/matplotlib/lib/matplotlib/mlab.py 2008年09月20日 03:21:19 UTC (rev 6115) +++ trunk/matplotlib/lib/matplotlib/mlab.py 2008年09月23日 18:22:54 UTC (rev 6116) @@ -2489,3 +2489,295 @@ zo = np.ma.masked_where(np.isnan(zo),zo) return zo griddata._reported = False + +################################################## +# Linear interpolation algorithms +################################################## +def less_simple_linear_interpolation( x, y, xi, extrap=False ): + """ + This function provides simple (but somewhat less so than + cbook.simple_linear_interpolation) linear interpolation. + simple_linear_interpolation will give a list of point between a + start and an end, while this does true linear interpolation at an + arbitrary set of points. + + This is very inefficient linear interpolation meant to be used + only for a small number of points in relatively non-intensive use + cases. For real linear interpolation, use scipy. + """ + if cbook.is_scalar(xi): xi = [xi] + + x = np.asarray(x) + y = np.asarray(y) + xi = np.asarray(xi) + + s = list(y.shape) + s[0] = len(xi) + yi = np.tile( np.nan, s ) + + for ii,xx in enumerate(xi): + bb = x == xx + if np.any(bb): + jj, = np.nonzero(bb) + yi[ii] = y[jj[0]] + elif xx<x[0]: + if extrap: + yi[ii] = y[0] + elif xx>x[-1]: + if extrap: + yi[ii] = y[-1] + else: + jj, = np.nonzero(x<xx) + jj = max(jj) + + yi[ii] = y[jj] + (xx-x[jj])/(x[jj+1]-x[jj]) * (y[jj+1]-y[jj]) + + return yi + +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 + +################################################## +# Code related to things in and around polygons +################################################## +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(xmin, xs, ys): + """ + given a sequence of xs and ys, return the vertices of a polygon + that has a horzontal base at xmin and an upper bound at the ys. + xmin is a scalar. + + intended for use with Axes.fill, eg + xv, yv = poly_below(0, x, y) + ax.fill(xv, yv) + """ + xs = np.asarray(xs) + ys = np.asarray(ys) + Nx = len(xs) + Ny = len(ys) + assert(Nx==Ny) + x = xmin*np.ones(2*Nx) + y = np.ones(2*Nx) + x[:Nx] = xs + y[:Nx] = ys + y[Nx:] = ys[::-1] + return x, y + + +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 + +def is_closed_polygon(X): + """ + Tests whether first and last object in a sequence are the same. These are + presumably coordinates on a polygonal curve, in which case this function + tests if that curve is closed. + + """ + return np.all(X[0] == X[-1]) + +################################################## +# Vector and path length geometry calculations +################################################## +def vector_lengths( X, P=2., axis=None ): + """ + Finds the length of a set of vectors in n dimensions. This is + like the numpy norm function for vectors, but has the ability to + work over a particular axis of the supplied array or matrix. + + Computes (sum((x_i)^P))^(1/P) for each {x_i} being the elements of X along + the given axis. If *axis* is *None*, compute over all elements of X. + """ + X = np.asarray(X) + return (np.sum(X**(P),axis=axis))**(1./P) + +def distances_along_curve( X ): + """ + Computes the distance between a set of successive points in N dimensions. + + where X is an MxN array or matrix. The distances between successive rows + is computed. Distance is the standard Euclidean distance. + """ + X = np.diff( X, axis=0 ) + return vector_lengths(X,axis=1) + +def path_length(X): + """ + Computes the distance travelled along a polygonal curve in N dimensions. + + + where X is an MxN array or matrix. Returns an array of length M consisting + of the distance along the curve at each point (i.e., the rows of X). + """ + X = distances_along_curve(X) + return np.concatenate( (np.zeros(1), np.cumsum(X)) ) + +def quad2cubic(q0x, q0y, q1x, q1y, q2x, q2y): + """ + Converts a quadratic Bezier curve to a cubic approximation. + + The inputs are the x and y coordinates of the three control points + of a quadratic curve, and the output is a tuple of x and y + coordinates of the four control points of the cubic curve. + """ + # c0x, c0y = q0x, q0y + c1x, c1y = q0x + 2./3. * (q1x - q0x), q0y + 2./3. * (q1y - q0y) + c2x, c2y = c1x + 1./3. * (q2x - q0x), c1y + 1./3. * (q2y - q0y) + # c3x, c3y = q2x, q2y + return q0x, q0y, c1x, c1y, c2x, c2y, q2x, q2y + Deleted: trunk/matplotlib/lib/matplotlib/numerical_methods.py =================================================================== --- trunk/matplotlib/lib/matplotlib/numerical_methods.py 2008年09月20日 03:21:19 UTC (rev 6115) +++ trunk/matplotlib/lib/matplotlib/numerical_methods.py 2008年09月23日 18:22:54 UTC (rev 6116) @@ -1,299 +0,0 @@ -""" -A collection of utility functions that do various numerical or geometrical -manipulations. -""" -import numpy as np -from numpy import ma -import matplotlib.cbook as cbook - -################################################## -# Linear interpolation algorithms -################################################## -def less_simple_linear_interpolation( x, y, xi, extrap=False ): - """ - This function provides simple (but somewhat less so than - cbook.simple_linear_interpolation) linear interpolation. - simple_linear_interpolation will give a list of point between a - start and an end, while this does true linear interpolation at an - arbitrary set of points. - - This is very inefficient linear interpolation meant to be used - only for a small number of points in relatively non-intensive use - cases. For real linear interpolation, use scipy. - """ - if cbook.is_scalar(xi): xi = [xi] - - x = np.asarray(x) - y = np.asarray(y) - xi = np.asarray(xi) - - s = list(y.shape) - s[0] = len(xi) - yi = np.tile( np.nan, s ) - - for ii,xx in enumerate(xi): - bb = x == xx - if np.any(bb): - jj, = np.nonzero(bb) - yi[ii] = y[jj[0]] - elif xx<x[0]: - if extrap: - yi[ii] = y[0] - elif xx>x[-1]: - if extrap: - yi[ii] = y[-1] - else: - jj, = np.nonzero(x<xx) - jj = max(jj) - - yi[ii] = y[jj] + (xx-x[jj])/(x[jj+1]-x[jj]) * (y[jj+1]-y[jj]) - - return yi - -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 - -################################################## -# Code related to things in and around polygons -################################################## -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(xmin, xs, ys): - """ - given a sequence of xs and ys, return the vertices of a polygon - that has a horzontal base at xmin and an upper bound at the ys. - xmin is a scalar. - - intended for use with Axes.fill, eg - xv, yv = poly_below(0, x, y) - ax.fill(xv, yv) - """ - xs = np.asarray(xs) - ys = np.asarray(ys) - Nx = len(xs) - Ny = len(ys) - assert(Nx==Ny) - x = xmin*np.ones(2*Nx) - y = np.ones(2*Nx) - x[:Nx] = xs - y[:Nx] = ys - y[Nx:] = ys[::-1] - return x, y - - -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 - -def is_closed_polygon(X): - """ - Tests whether first and last object in a sequence are the same. These are - presumably coordinates on a polygonal curve, in which case this function - tests if that curve is closed. - - """ - return np.all(X[0] == X[-1]) - -################################################## -# Vector and path length geometry calculations -################################################## -def vector_lengths( X, P=2., axis=None ): - """ - Finds the length of a set of vectors in n dimensions. This is - like the numpy norm function for vectors, but has the ability to - work over a particular axis of the supplied array or matrix. - - Computes (sum((x_i)^P))^(1/P) for each {x_i} being the elements of X along - the given axis. If *axis* is *None*, compute over all elements of X. - """ - X = np.asarray(X) - return (np.sum(X**(P),axis=axis))**(1./P) - -def distances_along_curve( X ): - """ - Computes the distance between a set of successive points in N dimensions. - - where X is an MxN array or matrix. The distances between successive rows - is computed. Distance is the standard Euclidean distance. - """ - X = np.diff( X, axis=0 ) - return vector_lengths(X,axis=1) - -def path_length(X): - """ - Computes the distance travelled along a polygonal curve in N dimensions. - - - where X is an MxN array or matrix. Returns an array of length M consisting - of the distance along the curve at each point (i.e., the rows of X). - """ - X = distances_along_curve(X) - return np.concatenate( (np.zeros(1), np.cumsum(X)) ) - -def quad2cubic(q0x, q0y, q1x, q1y, q2x, q2y): - """ - Converts a quadratic Bezier curve to a cubic approximation. - - The inputs are the x and y coordinates of the three control points - of a quadratic curve, and the output is a tuple of x and y - coordinates of the four control points of the cubic curve. - """ - # c0x, c0y = q0x, q0y - c1x, c1y = q0x + 2./3. * (q1x - q0x), q0y + 2./3. * (q1y - q0y) - c2x, c2y = c1x + 1./3. * (q2x - q0x), c1y + 1./3. * (q2y - q0y) - # c3x, c3y = q2x, q2y - return q0x, q0y, c1x, c1y, c2x, c2y, q2x, q2y - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 6115 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6115&view=rev Author: efiring Date: 2008年09月20日 03:21:19 +0000 (2008年9月20日) Log Message: ----------- fix bug in "angles='xy'" support in quiver Modified Paths: -------------- trunk/matplotlib/examples/tests/backend_driver.py trunk/matplotlib/lib/matplotlib/quiver.py Modified: trunk/matplotlib/examples/tests/backend_driver.py =================================================================== --- trunk/matplotlib/examples/tests/backend_driver.py 2008年09月19日 00:36:10 UTC (rev 6114) +++ trunk/matplotlib/examples/tests/backend_driver.py 2008年09月20日 03:21:19 UTC (rev 6115) @@ -50,6 +50,7 @@ 'customize_rc.py', 'date_demo1.py', 'date_demo2.py', + 'ellipse_collection.py', 'equal_aspect_ratio.py', 'errorbar_limits.py', 'fancybox_demo.py', Modified: trunk/matplotlib/lib/matplotlib/quiver.py =================================================================== --- trunk/matplotlib/lib/matplotlib/quiver.py 2008年09月19日 00:36:10 UTC (rev 6114) +++ trunk/matplotlib/lib/matplotlib/quiver.py 2008年09月20日 03:21:19 UTC (rev 6115) @@ -477,7 +477,7 @@ length = a/(self.scale*self.width) X, Y = self._h_arrows(length) if self.angles == 'xy': - theta = self._angles(U, V).filled(0) + theta = self._angles(U, V).filled(0)[:,np.newaxis] elif self.angles == 'uv': theta = np.angle(ma.asarray(uv[..., np.newaxis]).filled(0)) else: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 6114 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6114&view=rev Author: efiring Date: 2008年09月19日 00:36:10 +0000 (2008年9月19日) Log Message: ----------- Change quiver angles kwarg from radians to degrees Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/quiver.py Modified: trunk/matplotlib/lib/matplotlib/quiver.py =================================================================== --- trunk/matplotlib/lib/matplotlib/quiver.py 2008年09月19日 00:30:54 UTC (rev 6113) +++ trunk/matplotlib/lib/matplotlib/quiver.py 2008年09月19日 00:36:10 UTC (rev 6114) @@ -85,7 +85,7 @@ CCW from the *x*-axis. With 'xy', the arrow points from (x,y) to (x+u, y+v). Alternatively, arbitrary angles may be specified as an array - of values in radians, CCW from the *x*-axis. + of values in degrees, CCW from the *x*-axis. *scale*: [ None | float ] data units per arrow unit, e.g. m/s per plot width; a smaller @@ -481,7 +481,7 @@ elif self.angles == 'uv': theta = np.angle(ma.asarray(uv[..., np.newaxis]).filled(0)) else: - theta = ma.asarray(self.angles).filled(0) + theta = ma.asarray(self.angles*np.pi/180.0).filled(0) xy = (X+Y*1j) * np.exp(1j*theta)*self.width xy = xy[:,:,np.newaxis] XY = ma.concatenate((xy.real, xy.imag), axis=2) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.