How can I plot two lines in the same plot? The code below is my attempt to do that but it didn't work. 'Temp' is the new variable I added
(2nd EDITED )
from datetime import datetime
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
import numpy as np
from scipy.stats import mode
import re
linematchregex = re.compile('(\d+/\d+/\d+ \d+:\d+),(\d+\.\d+),(\d+\.\d+)')
startTime = datetime.strptime(raw_input('please enter start time in format like 21/7/2014 0:00 :'), '%d/%m/%Y %H:%M')
endTime = datetime.strptime(raw_input('please enter end time in format like 22/7/2014 23:57 :') , '%d/%m/%Y %H:%M')
with open(r'data.txt', 'r') as strm:
strm.next() #skip first line
t, y, temp = zip(*[p for line in strm for p in linematchregex.findall(line)])
t = [datetime.strptime(x, '%d/%m/%Y %H:%M') for x in t ]
temp = [float(x) for i,x in enumerate(temp) if startTime<=t[i]<=endTime]
y = [float(x) for i,x in enumerate(y) if startTime<=t[i]<=endTime]
t = [x for x in t if startTime<=x<=endTime]
fig = plt.figure()
ax1 = fig.add_subplot(1, 1, 1, axisbg='white')
ax1.xaxis.set_major_formatter(mdates.DateFormatter('%H:%M'))
ax1.plot(t, y, 'c', linewidth=3.3)
ax1.plot(t, temp)
plt.show()
My Program can plot TimeStamp with Irradiance but how can i plot all the columns below Time with Irradiance & Time with Temperature
(EDITED)
TimeStamp,Irradiance,Ambient_Temperature
21/7/2014 12:00:06 AM,0.66,29.16
21/7/2014 12:00:20 AM,0.71,29.16
21/7/2014 12:00:34 AM,0.65,29.17
21/7/2014 12:00:48 AM,0.67,29.17
21/7/2014 12:01:08 AM,0.58,29.17
21/7/2014 12:01:23 AM,0.54,29.18
21/7/2014 12:01:37 AM,0.63,29.17
21/7/2014 12:01:52 AM,0.65,29.16
21/7/2014 12:02:07 AM,0.64,29.16
21/7/2014 12:02:22 AM,0.63,29.18
21/7/2014 12:02:36 AM,0.63,29.16
21/7/2014 12:02:50 AM,0.64,29.17
21/7/2014 12:03:04 AM,0.62,29.19
21/7/2014 12:03:24 AM,0.64,29.21