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
(2) |
2
(2) |
3
(2) |
4
|
5
(2) |
6
(4) |
7
|
8
|
9
|
10
|
11
|
12
|
13
(1) |
14
(2) |
15
(3) |
16
(7) |
17
(1) |
18
(1) |
19
(3) |
20
(16) |
21
(3) |
22
(4) |
23
(2) |
24
|
25
|
26
(6) |
27
(3) |
28
(9) |
29
(2) |
30
(2) |
|
Revision: 8263 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8263&view=rev Author: efiring Date: 2010年04月21日 21:49:53 +0000 (2010年4月21日) Log Message: ----------- simpletest_oo.py: remove inactive lines, improve readability Modified Paths: -------------- trunk/toolkits/basemap/examples/simpletest_oo.py Modified: trunk/toolkits/basemap/examples/simpletest_oo.py =================================================================== --- trunk/toolkits/basemap/examples/simpletest_oo.py 2010年04月21日 21:47:13 UTC (rev 8262) +++ trunk/toolkits/basemap/examples/simpletest_oo.py 2010年04月21日 21:49:53 UTC (rev 8263) @@ -1,28 +1,32 @@ -##################################### -# pylab-free version of simpletest.py -##################################### -# set backend to Agg. -import matplotlib -matplotlib.use('Agg') +###################################### +# pyplot-free version of simpletest.py +###################################### + +import numpy as np + from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas -from mpl_toolkits.basemap import Basemap from matplotlib.figure import Figure -import numpy as np import matplotlib.cm as cm +from mpl_toolkits.basemap import Basemap + # read in topo data (on a regular lat/lon grid) # longitudes go from 20 to 380. etopo = np.loadtxt('etopo20data.gz') lons = np.loadtxt('etopo20lons.gz') lats = np.loadtxt('etopo20lats.gz') + # create figure. fig = Figure() canvas = FigureCanvas(fig) + # create axes instance, leaving room for colorbar at bottom. ax = fig.add_axes([0.125,0.175,0.75,0.75]) + # create Basemap instance for Robinson projection. # set 'ax' keyword so pylab won't be imported. m = Basemap(projection='robin',lon_0=0.5*(lons[0]+lons[-1]),ax=ax) + # make filled contour plot. x, y = m(*np.meshgrid(lons, lats)) cs = m.contourf(x,y,etopo,30,cmap=cm.jet) @@ -35,12 +39,15 @@ m.drawmeridians(np.arange(0.,420.,60.),labels=[0,0,0,1],fontsize=10) # add a title. ax.set_title('Robinson Projection') + # add a colorbar. pos = ax.get_position() l, b, w, h = pos.bounds cax = fig.add_axes([l, b-0.1, w, 0.03],frameon=False) # setup colorbar axes -fig.colorbar(cs, cax=cax, orientation='horizontal',ticks=cs.levels[::3]) +fig.colorbar(cs, cax=cax, orientation='horizontal',ticks=cs.levels[::3]) + # save image (width 800 pixels with dpi=100 and fig width 8 inches). canvas.print_figure('simpletest',dpi=100) # done. print 'image saved in simpletest.png' + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 8262 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8262&view=rev Author: efiring Date: 2010年04月21日 21:47:13 +0000 (2010年4月21日) Log Message: ----------- Remove some pre-mpl-0.98 support 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 2010年04月21日 20:24:27 UTC (rev 8261) +++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2010年04月21日 21:47:13 UTC (rev 8262) @@ -2660,10 +2660,7 @@ ax.hold(b) # reset current active image (only if pyplot is imported). if plt: - try: - plt.sci(ret) - except AttributeError: - plt.gci._current = ret + plt.sci(ret) # set axes limits to fit map region. self.set_axes_limits(ax=ax) return ret @@ -2725,10 +2722,7 @@ ax.hold(b) # reset current active image (only if pyplot is imported). if plt: - try: - plt.sci(ret) - except AttributeError: - plt.gci._current = ret + plt.sci(ret) # set axes limits to fit map region. self.set_axes_limits(ax=ax) return ret @@ -2764,10 +2758,7 @@ ax.hold(b) # reset current active image (only if pyplot is imported). if plt: - try: - plt.sci(ret) - except AttributeError: - plt.gci._current = ret + plt.sci(ret) # set axes limits to fit map region. self.set_axes_limits(ax=ax) return ret @@ -2795,10 +2786,7 @@ ax.hold(b) # reset current active image (only if pyplot is imported). if plt: - try: - plt.sci(ret) - except AttributeError: - plt.gci._current = ret + plt.sci(ret) # set axes limits to fit map region. self.set_axes_limits(ax=ax) return ret @@ -2848,22 +2836,11 @@ ax.hold(b) raise ax.hold(b) + # reset current active image (only if pyplot is imported). + if plt and CS.get_array() is not None: + plt.sci(CS) # set axes limits to fit map region. self.set_axes_limits(ax=ax) - # reset current active image (only if pyplot is imported). - if plt: - try: # new contour. - if CS._A is not None: - try: - plt.sci(CS) - except AttributeError: - plt.gci._current = CS - except: # old contour. - if CS[1].mappable is not None: - try: - plt.sci(CS[1].mappable) - except AttributeError: - plt.gci._current = CS[1].mappable return CS def contourf(self,x,y,data,*args,**kwargs): @@ -2922,22 +2899,11 @@ ax.hold(b) raise ax.hold(b) + # reset current active image (only if pyplot is imported). + if plt and CS.get_array() is not None: + plt.sci(CS) # set axes limits to fit map region. self.set_axes_limits(ax=ax) - # reset current active image (only if pyplot is imported). - if plt: - try: # new contour. - if CS._A is not None: - try: - plt.sci(CS) - except AttributeError: - plt.gci._current = CS - except: # old contour. - if CS[1].mappable is not None: - try: - plt.sci(CS[1].mappable) - except AttributeError: - plt.gci._current = CS[1].mappable return CS def quiver(self, x, y, u, v, *args, **kwargs): @@ -3006,7 +2972,7 @@ # Because there are two collections returned in general, # we can't set the current image... #if plt is not None and ret.get_array() is not None: - # plt.sci(ret) + # plt.sci(retnh) # set axes limits to fit map region. self.set_axes_limits(ax=ax) return retnh,retsh This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
Revision: 8261 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8261&view=rev Author: efiring Date: 2010年04月21日 20:24:27 +0000 (2010年4月21日) Log Message: ----------- Remove redundant operations, especially forced drawing in interactive mode 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 2010年04月20日 22:37:01 UTC (rev 8260) +++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2010年04月21日 20:24:27 UTC (rev 8261) @@ -30,7 +30,7 @@ higher, you have version %s""" % (_mpl_required_version,_matplotlib_version)) raise ImportError(msg) -from matplotlib import rcParams, is_interactive, _pylab_helpers +from matplotlib import rcParams, is_interactive from matplotlib.collections import LineCollection from matplotlib.patches import Ellipse, Circle, Polygon from matplotlib.lines import Line2D @@ -41,7 +41,6 @@ import numpy.ma as ma from shapelib import ShapeFile import _geoslib, netcdftime -import cm # basemap data files now installed in lib/matplotlib/toolkits/basemap/data # check to see if environment variable BASEMAPDATA set to a directory, @@ -313,7 +312,7 @@ latitude circle boundinglat is tangent to the edge of the map at lon_0. satellite_height height of satellite (in m) above equator - - only relevant for geostationary + only relevant for geostationary and near-sided perspective (``geos`` or ``nsper``) projections. Default 35,786 km. ================ ==================================================== @@ -760,6 +759,8 @@ # if ax == None, pyplot.gca may be used. self.ax = ax self.lsmask = None + # This will record hashs of Axes instances. + self._initialized_axes = set() # set defaults for area_thresh. self.resolution = resolution @@ -2583,11 +2584,33 @@ def set_axes_limits(self,ax=None): """ + Final step in Basemap method wrappers of Axes plotting methods: + Set axis limits, fix aspect ratio for map domain using current - or specified axes instance. + or specified axes instance. This is done only once per axes + instance. + + In interactive mode, this method always calls draw_if_interactive + before returning. + """ # get current axes instance (if none specified). ax = ax or self._check_ax() + + # If we have already set the axes limits, and if the user + # has not defeated this by turning autoscaling back on, + # then all we need to do is plot if interactive. + if (hash(ax) in self._initialized_axes + and not ax.get_autoscalex_on() + and not ax.get_autoscaley_on()): + if is_interactive(): + import matplotlib.pyplot as plt + plt.draw_if_interactive() + return + + self._initialized_axes.add(hash(ax)) + # Take control of axis scaling: + ax.set_autoscale_on(False) # update data limits for map domain. corners = ((self.llcrnrx,self.llcrnry), (self.urcrnrx,self.urcrnry)) ax.update_datalim( corners ) @@ -2605,15 +2628,14 @@ ax.set_aspect('equal',adjustable='box',anchor=self.anchor) else: ax.set_aspect('auto',adjustable='box',anchor=self.anchor) - ax.apply_aspect() # make sure axis ticks are turned off. if self.noticks: ax.set_xticks([]) ax.set_yticks([]) # force draw if in interactive mode. if is_interactive(): - figManager = _pylab_helpers.Gcf.get_active() - figManager.canvas.draw() + import matplotlib.pyplot as plt + plt.draw_if_interactive() def scatter(self, *args, **kwargs): """ @@ -2624,10 +2646,7 @@ Other \**kwargs passed on to matplotlib.pyplot.scatter. """ - ax = kwargs.pop('ax', None) or self._check_ax() - # if ax kwarg not supplied, and ax attribute not set, import pyplot. - if self.ax is None and kwargs.pop('ax', None) is None: - import matplotlib.pyplot as plt + ax, plt = self._ax_plt_from_kw(kwargs) # allow callers to override the hold state by passing hold=True|False b = ax.ishold() h = kwargs.pop('hold',None) @@ -2635,22 +2654,16 @@ ax.hold(h) try: ret = ax.scatter(*args, **kwargs) - try: - plt.draw_if_interactive() - except: - pass except: ax.hold(b) raise ax.hold(b) # reset current active image (only if pyplot is imported). - try: + if plt: try: plt.sci(ret) except AttributeError: plt.gci._current = ret - except: - pass # set axes limits to fit map region. self.set_axes_limits(ax=ax) return ret @@ -2672,10 +2685,6 @@ ax.hold(h) try: ret = ax.plot(*args, **kwargs) - try: - plt.draw_if_interactive() - except: - pass except: ax.hold(b) raise @@ -2698,10 +2707,7 @@ returns an matplotlib.image.AxesImage instance. """ - ax = kwargs.pop('ax', None) or self._check_ax() - # if ax kwarg not supplied, and ax attribute not set, import pyplot. - if self.ax is None and kwargs.pop('ax', None) is None: - import matplotlib.pyplot as plt + ax, plt = self._ax_plt_from_kw(kwargs) kwargs['extent']=(self.llcrnrx,self.urcrnrx,self.llcrnry,self.urcrnry) # use origin='lower', unless overridden. if not kwargs.has_key('origin'): @@ -2713,22 +2719,16 @@ ax.hold(h) try: ret = ax.imshow(*args, **kwargs) - try: - plt.draw_if_interactive() - except: - pass except: ax.hold(b) raise ax.hold(b) # reset current active image (only if pyplot is imported). - try: + if plt: try: plt.sci(ret) except AttributeError: plt.gci._current = ret - except: - pass # set axes limits to fit map region. self.set_axes_limits(ax=ax) return ret @@ -2746,10 +2746,7 @@ Other \**kwargs passed on to matplotlib.pyplot.pcolor. """ - ax = kwargs.pop('ax', None) or self._check_ax() - # if ax kwarg not supplied, and ax attribute not set, import pyplot. - if self.ax is None and kwargs.pop('ax', None) is None: - import matplotlib.pyplot as plt + ax, plt = self._ax_plt_from_kw(kwargs) # make x,y masked arrays # (masked where data is outside of projection limb) x = ma.masked_values(np.where(x > 1.e20,1.e20,x), 1.e20) @@ -2761,22 +2758,16 @@ ax.hold(h) try: ret = ax.pcolor(x,y,data,**kwargs) - try: - plt.draw_if_interactive() - except: - pass except: ax.hold(b) raise ax.hold(b) # reset current active image (only if pyplot is imported). - try: + if plt: try: plt.sci(ret) except AttributeError: plt.gci._current = ret - except: - pass # set axes limits to fit map region. self.set_axes_limits(ax=ax) return ret @@ -2790,10 +2781,7 @@ Other \**kwargs passed on to matplotlib.pyplot.pcolormesh. """ - ax = kwargs.pop('ax', None) or self._check_ax() - # if ax kwarg not supplied, and ax attribute not set, import pyplot. - if self.ax is None and kwargs.pop('ax', None) is None: - import matplotlib.pyplot as plt + ax, plt = self._ax_plt_from_kw(kwargs) # allow callers to override the hold state by passing hold=True|False b = ax.ishold() h = kwargs.pop('hold',None) @@ -2801,22 +2789,16 @@ ax.hold(h) try: ret = ax.pcolormesh(x,y,data,**kwargs) - try: - plt.draw_if_interactive() - except: - pass except: ax.hold(b) raise ax.hold(b) # reset current active image (only if pyplot is imported). - try: + if plt: try: plt.sci(ret) except AttributeError: plt.gci._current = ret - except: - pass # set axes limits to fit map region. self.set_axes_limits(ax=ax) return ret @@ -2830,10 +2812,7 @@ Other \*args and \**kwargs passed on to matplotlib.pyplot.contour. """ - ax = kwargs.pop('ax', None) or self._check_ax() - # if ax kwarg not supplied, and ax attribute not set, import pyplot. - if self.ax is None and kwargs.pop('ax', None) is None: - import matplotlib.pyplot as plt + ax, plt = self._ax_plt_from_kw(kwargs) # make sure x is monotonically increasing - if not, # print warning suggesting that the data be shifted in longitude # with the shiftgrid function. @@ -2865,10 +2844,6 @@ ax.hold(h) try: CS = ax.contour(x,y,data,*args,**kwargs) - try: - plt.draw_if_interactive() - except: - pass except: ax.hold(b) raise @@ -2876,7 +2851,7 @@ # set axes limits to fit map region. self.set_axes_limits(ax=ax) # reset current active image (only if pyplot is imported). - try: + if plt: try: # new contour. if CS._A is not None: try: @@ -2889,8 +2864,6 @@ plt.sci(CS[1].mappable) except AttributeError: plt.gci._current = CS[1].mappable - except: - pass return CS def contourf(self,x,y,data,*args,**kwargs): @@ -2905,10 +2878,7 @@ Other \*args and \**kwargs passed on to matplotlib.pyplot.scatter. """ - ax = kwargs.pop('ax', None) or self._check_ax() - # if ax kwarg not supplied, and ax attribute not set, import pyplot. - if self.ax is None and kwargs.pop('ax', None) is None: - import matplotlib.pyplot as plt + ax, plt = self._ax_plt_from_kw(kwargs) # make sure x is monotonically increasing - if not, # print warning suggesting that the data be shifted in longitude # with the shiftgrid function. @@ -2948,10 +2918,6 @@ ax.hold(h) try: CS = ax.contourf(x,y,data,*args,**kwargs) - try: - plt.draw_if_interactive() - except: - pass except: ax.hold(b) raise @@ -2959,7 +2925,7 @@ # set axes limits to fit map region. self.set_axes_limits(ax=ax) # reset current active image (only if pyplot is imported). - try: + if plt: try: # new contour. if CS._A is not None: try: @@ -2972,8 +2938,6 @@ plt.sci(CS[1].mappable) except AttributeError: plt.gci._current = CS[1].mappable - except: - pass return CS def quiver(self, x, y, u, v, *args, **kwargs): @@ -2985,10 +2949,7 @@ Other \*args and \**kwargs passed on to matplotlib.pyplot.quiver. """ - ax = kwargs.pop('ax', None) or self._check_ax() - # if ax kwarg not supplied, and ax attribute not set, import pyplot. - if self.ax is None and kwargs.pop('ax', None) is None: - import matplotlib.pyplot as plt + ax, plt = self._ax_plt_from_kw(kwargs) # allow callers to override the hold state by passing hold=True|False b = ax.ishold() h = kwargs.pop('hold',None) @@ -2996,14 +2957,12 @@ ax.hold(h) try: ret = ax.quiver(x,y,u,v,*args,**kwargs) - try: - plt.draw_if_interactive() - except: - pass except: ax.hold(b) raise ax.hold(b) + if plt is not None and ret.get_array() is not None: + plt.sci(ret) # set axes limits to fit map region. self.set_axes_limits(ax=ax) return ret @@ -3025,10 +2984,7 @@ barb method requires matplotlib 0.98.3 or higher, you have %s""" % _matplotlib_version) raise NotImplementedError(msg) - ax = kwargs.pop('ax', None) or self._check_ax() - # if ax kwarg not supplied, and ax attribute not set, import pyplot. - if self.ax is None and kwargs.pop('ax', None) is None: - import matplotlib.pyplot as plt + ax, plt = self._ax_plt_from_kw(kwargs) # allow callers to override the hold state by passing hold=True|False b = ax.ishold() h = kwargs.pop('hold',None) @@ -3043,14 +2999,14 @@ retnh = ax.barbs(x,y,unh,vnh,*args,**kwargs) kwargs['flip_barb']=True retsh = ax.barbs(x,y,ush,vsh,*args,**kwargs) - try: - plt.draw_if_interactive() - except: - pass except: ax.hold(b) raise ax.hold(b) + # Because there are two collections returned in general, + # we can't set the current image... + #if plt is not None and ret.get_array() is not None: + # plt.sci(ret) # set axes limits to fit map region. self.set_axes_limits(ax=ax) return retnh,retsh @@ -3595,6 +3551,24 @@ ax = self.ax return ax + def _ax_plt_from_kw(self, kw): + """ + Return (ax, plt), where ax is the current axes, and plt is + None or a reference to the pyplot module. + + plt will be None if ax was popped from kw or taken from self.ax; + otherwise, pyplot was used and is returned. + """ + plt = None + _ax = kw.pop('ax', None) + if _ax is None: + _ax = self.ax + if _ax is None: + import matplotlib.pyplot as plt + _ax = plt.gca() + return _ax, plt + + ### End of Basemap class def _searchlist(a,x): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.