Mauro Cavalcanti wrote: > Dear Jeff & ALL, > > How can I get rid, programmatically, of lines drawn with the > drawparallels and drawmeridians in MPL/Basemap? These methods return > dictionaries, but calling the Python clear() method for dictionaries > (and redrawing the figure as usual, of course) does not work. No error > appears, simply nothing happens. > > Any hints? > > Thanks in advance! > > Best regards, > > Mauro: From the docstring
"returns a dictionary whose keys are the parallel values, and whose values are tuples containing lists of the matplotlib.lines.Line2D and matplotlib.text.Text instances associated with each parallel." So, if "pd" is the dict returned by drawparallels, pd[30] would be a tuple of lists of Line2D and Text instances associated with the 30 degree parallel. You can call the remove() method on each of the items in those lists to remove them from the plot. For example, [jsws-MacBook:~] jwhitaker% ipython2.5 -pylab Python 2.5.4 (r254:67916, Jan 9 2009, 07:06:45) Type "copyright", "credits" or "license" for more information. IPython 0.9.1 -- An enhanced Interactive Python. ? -> Introduction and overview of IPython's features. %quickref -> Quick reference. help -> Python's own help system. object? -> Details about 'object'. ?object also works, ?? prints more. Welcome to pylab, a matplotlib-based Python environment. For more information, type 'help(pylab)'. In [1]: from mpl_toolkits.basemap import Basemap In [2]: m = Basemap() In [9]: pd=m.drawparallels(range(0,90,30),labels=[1,0,0,0]) In [10]: pd Out[10]: {0: ([<matplotlib.lines.Line2D object at 0x17ea2bd0>], [<matplotlib.text.Text object at 0x17eab1f0>]), 30: ([<matplotlib.lines.Line2D object at 0x17ea2d30>], [<matplotlib.text.Text object at 0x17eab270>]), 60: ([<matplotlib.lines.Line2D object at 0x17ea2f30>], [<matplotlib.text.Text object at 0x17eab2f0>])} In [11]: pd[30] Out[11]: ([<matplotlib.lines.Line2D object at 0x17ea2d30>], [<matplotlib.text.Text object at 0x17eab270>]) In [12]: pd[30][0][0] Out[12]: <matplotlib.lines.Line2D object at 0x17ea2d30> In [13]: pd[30][0][0].remove() HTH, -Jeff ------------------------------------------------------------------------------ Check out the new SourceForge.net Marketplace. It is the best place to buy or sell services for just about anything Open Source. http://p.sf.net/sfu/Xq1LFB _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users