|
From: <js...@us...> - 2010-09-08 13:47:20
|
Revision: 8688
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8688&view=rev
Author: jswhit
Date: 2010-09-08 13:47:13 +0000 (Wed, 08 Sep 2010)
Log Message:
-----------
deleting an item from parallels/meridians dict removes it from plot.
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-08 12:21:50 UTC (rev 8687)
+++ trunk/toolkits/basemap/Changelog 2010-09-08 13:47:13 UTC (rev 8688)
@@ -1,4 +1,7 @@
version 1.0.1 (not yet released).
+ * Deleting an item from the dicts returned by drawparallels
+ and drawmeridians removes the corresponding parallel or meridian (and
+ associated labels) from the plot.
* add a remove method to the tuples that are returned in
the dicts returned by drawparallels and drawmeridians.
* add removeparallels and removemeridians convenience methods.
Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py
===================================================================
--- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2010-09-08 12:21:50 UTC (rev 8687)
+++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2010-09-08 13:47:13 UTC (rev 8688)
@@ -1814,11 +1814,10 @@
============== ====================================================
returns a dictionary whose keys are the parallel values, and
- whose values are tuple-like objects containing lists of the
+ whose values are tuples containing lists of the
matplotlib.lines.Line2D and matplotlib.text.Text instances
- associated with each parallel. Each one of these tuple-like
- objects has a ``remove`` method so it can be easily removed
- from the plot.
+ associated with each parallel. Deleting an item from the
+ dictionary removes the corresponding parallel from the plot.
"""
# get current axes instance (if none specified).
ax = ax or self._check_ax()
@@ -2019,7 +2018,7 @@
if v == ([], []): del linecolls[k]
# add a remove method to each tuple.
linecolls[k] = _tup(linecolls[k])
- return linecolls
+ return _dict(linecolls)
def drawmeridians(self,meridians,color='k',linewidth=1., zorder=None,\
dashes=[1,1],labels=[0,0,0,0],labelstyle=None,\
@@ -2070,11 +2069,10 @@
============== ====================================================
returns a dictionary whose keys are the meridian values, and
- whose values are tuple-like objects containing lists of the
+ whose values are tuples containing lists of the
matplotlib.lines.Line2D and matplotlib.text.Text instances
- associated with each meridian. Each one of these tuple-like
- objects has a ``remove`` method so it can be easily removed
- from the plot.
+ associated with each meridian. Deleting an item from the
+ dictionary removes the correpsonding meridian from the plot.
"""
# get current axes instance (if none specified).
ax = ax or self._check_ax()
@@ -2266,7 +2264,7 @@
if v == ([], []): del linecolls[k]
# add a remove method to each tuple.
linecolls[k] = _tup(linecolls[k])
- return linecolls
+ return _dict(linecolls)
def tissot(self,lon_0,lat_0,radius_deg,npts,ax=None,**kwargs):
"""
@@ -4156,3 +4154,8 @@
except ValueError:
# don't raise an error if item already removed
pass
+class _dict(dict):
+ # override __delitem__ to first call remove method on values.
+ def __delitem__(self,key):
+ self[key].remove()
+ super(_dict, self).__delitem__(key)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|