2012-02-20 46 views
1

我正在尋找方法或東西,這將允許我刪除一個事情(我知道cla()將清除整個),例如從軸線,如:Matplotlib - 從軸上刪除東西

x = self.plt.plot([5*a,0],[0,5*b], color = 'black') 
self.plt.draw() 
#here I want to to remove x, calculate new position and draw again 

一切都在互動模式下完成。

回答

3
[email protected]:~/sweethome/temp$ python 
Python 2.6.5 (r265:79063, Apr 16 2010, 13:57:41) 
[GCC 4.4.3] on linux2 
Type "help", "copyright", "credits" or "license" for more information. 
>>> import matplotlib.pyplot as plt 
>>> plt.ion() 
>>> l,=plt.plot([1,2,3],[4,5,6],'bo-')  # a figure pops up 
>>> l.remove()        # nothing happens 
>>> plt.draw()        # don't forget to redraw 
>>> 

但是如果你只想要更改的元素,你可以使用set_ydata(...)其次draw()代替。