python - Plotting 2 arrays against another on one graph -


i want compare how 2 independent variables vary time, plotting both of them on 1 graph. 3 variables in form of arrays, pulled text file. have got far:

from pylab import *  data_ = []  open('all_the_data.txt') dat_:     line in dat_:         data_.append([i in line.split()])  d = zip(*data_)  def f1(t):     y = d[1]     return y  def f2(t):     y = d[2]     return y  if __name__ == '__main__':     t = d[0]     = f1     b = f2     plot(t, a, 'bo')     hold('on')     plot(t, b, 'gx')     xlabel('timestamp (unix)')     ylabel('station population')     legend('station 1','station 2')     title('variance of stations 1 , 2')     show()     savefig('2_stations_vs_time.png') 

problem is, isn't working, , don't know why. got tutorial on graphing 2 functions.

we plot data not function. pass a, b wrong. think need is:

from pylab import *  data_ = []  open('all_the_data.txt') dat_:     line in dat_:         data_.append([i in line.split()])  d = zip(*data_)  if __name__ == '__main__':     t = d[0]     = d[1]     b = d[2]     plot(t, a, 'bo')     hold('on')     plot(t, b, 'gx')     xlabel('timestamp (unix)')     ylabel('station population')     legend('station 1','station 2')     title('variance of stations 1 , 2')     show()     savefig('2_stations_vs_time.png') 

i have tested if d right value, example d = [list(range(100)), list(range(10, 110)), list(range(20, 120))]. code works well.


Comments