파이썬 용 플로팅 라이브러리를 사용하고 있으며 이미 전투 테스트를 거쳐 입증 된 matplotlib를 발견했습니다. 그러나 스레드에서 간단한 줄거리를 만드는 동안 문제를 발견했습니다. 예 울부 짖는 소리에 matplotlib 간단한 스레드에서 멈추는 플로팅
, 더미 클래스 방법은 두 번 연속 스레드에서 실행 plotme하지만 2 차 반복에 갇혀/정지를 가져옵니다. 스레딩 자체와 관련하여 분명하고 관련이있는 항목이 많지만 지금까지는 그 문제점을 발견하지 못했습니다.import matplotlib.pyplot as plt
from numpy import arange, sin, pi
import threading
class Dummy():
def plotme(self, iteration = 1):
print "%ix plotting... " % iteration,
t = arange(0.0, 2.0, 0.01)
s = sin(2*pi*t)
plt.plot(t, s)
plt.xlabel('time (s)')
plt.ylabel('voltage (mV)')
plt.title('About as simple as it gets, folks')
#savefig("test.png") # irrelevant here
plt.close()
def threadme(self, iteration = 1):
thread_plot = threading.Thread(target=self.plotme,
args=(iteration,))
thread_plot.start()
thread_plot.join()
dummy = Dummy()
dummy.threadme(1)
dummy.threadme(2)
당신이 알고 matplotlib.pyplot의 명령 것을 있습니까 hread-safe가 아닌가? 당신은 그림, 축 객체를 생성 한 다음이 축 객체에 대한 메소드를 호출하는 것과 같은 OOUP 접근법을 사용해야합니다. 'ax.plot (...)' –