|
From: <js...@us...> - 2010-09-08 12:00:38
|
Revision: 8686
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8686&view=rev
Author: jswhit
Date: 2010-09-08 12:00:32 +0000 (Wed, 08 Sep 2010)
Log Message:
-----------
reconsider removeparallels and removemeridians. Add remove method to tuples contained
in dicts returned by drawparallels and drawmeridians instead.
Modified Paths:
--------------
trunk/toolkits/basemap/Changelog
trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py
Modified: trunk/toolkits/basemap/Changelog
===================================================================
--- trunk/toolkits/basemap/Changelog 2010-09-07 23:15:27 UTC (rev 8685)
+++ trunk/toolkits/basemap/Changelog 2010-09-08 12:00:32 UTC (rev 8686)
@@ -1,6 +1,6 @@
version 1.0.1 (not yet released).
- * add datum grid shift files, so that pyproj.transform can do datum
- shifts.
+ * add a remove method to the tuples that are returned in
+ the dicts returned by drawparallels and drawmeridians.
* add removeparallels and removemeridians convenience methods.
version 1.0 (svn revision 8531)
* don't force adjustable='box' so Basemap is compatible
Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py
===================================================================
--- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2010-09-07 23:15:27 UTC (rev 8685)
+++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2010-09-08 12:00:32 UTC (rev 8686)
@@ -1814,9 +1814,11 @@
============== ====================================================
returns a dictionary whose keys are the parallel values, and
- whose values are tuples containing lists of the
+ whose values are tuple-like objects containing lists of the
matplotlib.lines.Line2D and matplotlib.text.Text instances
- associated with each parallel.
+ associated with each parallel. Each one of these tuple-like
+ objects has a ``remove`` method so it can be easily removed
+ from the plot.
"""
# get current axes instance (if none specified).
ax = ax or self._check_ax()
@@ -2015,41 +2017,10 @@
keys = linecolls.keys(); vals = linecolls.values()
for k,v in zip(keys,vals):
if v == ([], []): del linecolls[k]
+ # add a remove method to each tuple.
+ linecolls[k] = _tup(linecolls[k])
return linecolls
- def removeparallels(self,pdict,lat=None,ax=None):
- """
- Given a dictionary returned by :meth:`Basemap.drawparallels`, remove
- parallels (latitude lines) and associated labels from the map.
-
- .. tabularcolumns:: |l|L|
-
- ============== ====================================================
- Keyword Description
- ============== ====================================================
- lat latitude value to remove (Default None, removes all
- of them)
- ax axes instance (overrides default axes instance)
- ============== ====================================================
- """
- if lat is not None and lat not in pdict.keys():
- raise ValueError('latitude %s not drawn' % lat)
- for key in pdict.keys():
- if lat is None or key == lat:
- tup = pdict[key]
- for item in tup:
- for x in item:
- try:
- x.remove()
- # might already be removed, if so
- # don't do anything (exit silently).
- except ValueError:
- pass
- # get current axes instance (if none specified).
- ax = ax or self._check_ax()
- # set axes limits to fit map region.
- self.set_axes_limits(ax=ax)
-
def drawmeridians(self,meridians,color='k',linewidth=1., zorder=None,\
dashes=[1,1],labels=[0,0,0,0],labelstyle=None,\
fmt='%g',xoffset=None,yoffset=None,ax=None,latmax=None,
@@ -2099,9 +2070,11 @@
============== ====================================================
returns a dictionary whose keys are the meridian values, and
- whose values are tuples containing lists of the
+ whose values are tuple-like objects containing lists of the
matplotlib.lines.Line2D and matplotlib.text.Text instances
- associated with each meridian.
+ associated with each meridian. Each one of these tuple-like
+ objects has a ``remove`` method so it can be easily removed
+ from the plot.
"""
# get current axes instance (if none specified).
ax = ax or self._check_ax()
@@ -2291,27 +2264,10 @@
keys = linecolls.keys(); vals = linecolls.values()
for k,v in zip(keys,vals):
if v == ([], []): del linecolls[k]
+ # add a remove method to each tuple.
+ linecolls[k] = _tup(linecolls[k])
return linecolls
- def removemeridians(self,mdict,lon=None):
- """
- Given a dictionary returned by :meth:`Basemap.drawmeridians`, remove
- meridians (longitude lines) and associated labels from the map.
-
- .. tabularcolumns:: |l|L|
-
- ============== ====================================================
- Keyword Description
- ============== ====================================================
- lon longitude value to remove (Default None, removes all
- of them)
- ax axes instance (overrides default axes instance)
- ============== ====================================================
- """
- if lon is not None and lon not in mdict.keys():
- raise ValueError('longitude %s not drawn' % lon)
- self.removeparallels(mdict,lat=lon)
-
def tissot(self,lon_0,lat_0,radius_deg,npts,ax=None,**kwargs):
"""
Draw a polygon centered at ``lon_0,lat_0``. The polygon
@@ -4188,3 +4144,11 @@
lsmask = tmparr
lsmaskf.close()
return lsmask_lons, lsmask_lats, lsmask
+
+class _tup(tuple):
+ # tuple with an added remove method.
+ # used for objects returned by drawparallels and drawmeridians.
+ def remove(self):
+ for item in self:
+ for x in item:
+ x.remove()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|