2012-01-23 28 views
1

私はスクリプトの実行中に軸を更新できるメソッドを探していますが、見つけられませんでした。たとえば、次のように続いて更新するようにドローを呼び出しMatplotlib更新軸

plt.ion() 

import matplotlib.pyplot as plt 

x = (1,2) 
y = (1,2) 

plt.plot(x,y, 'r-') 
plt.show() 

#here during run of program I want to clear axis with help of plt.cla() and update it 
#new one 

# x = (2,4) 
# y = (2,4) 
#plt.plot(x,y, 'b-') 

答えて

2

あなたはおそらく、対話型モードにmatplotlibのを設定する必要な機能を取得します。例:

import numpy 
import time 
x = (1,2) 
y = (1,2) 
plt.ion() 
plt.plot(x,y, 'r-') 
plt.draw() 

for i in range(100): 
    print i 
    time.sleep(1) 
    plt.cla() 
    y = (numpy.random.normal(), numpy.random.normal()) 
    plt.plot(x,y, 'r-') 
    plt.draw() 
関連する問題