擅长:python、mysql、java
<p>编辑:我认为问题可能在于你如何提取数据。当您调用<code>A=f1</code>和<code>B=f2</code>时,您应该编写<code>A=f1(t)</code>和<code>B=f2(t)</code>,以符合您构造<code>f1</code>和<code>f2</code>的方式。但是,为什么要这样做呢?</p>
<pre><code>with open('all_the_data.txt', 'r') as dat_:
for line in dat_:
data_.append([i for i in line.strip().split()])
D = zip(*data_)
t = D[0]
A = D[1]
B = D[2]
</code></pre>
<p>对于绘图,我更喜欢面向对象的方法。</p>
<pre><code>import matplotlib.pyplot as plt
f = plt.figure()
ax = f.add_subplot(111)
ax.plot(t, A, 'bo', label="Station 1")
ax.plot(t, B, 'gX', label="station 2")
ax.legend()
ax.set_xlabel('timestamp (unix)')
ax.set_ylabel('Station population')
ax.set_title('Variance of Stations 1 and 2')
f.savefig('2_stations_vs_time.png')
</code></pre>