Hi, this program of mine can plot timestamp & irradiance but how can i plot another line of data for temperature?
This is my txt data:
TimeStamp,Irradiance,Temperature
21/7/2014 0:00,0.66,26.2
21/7/2014 0:00,0.71,23.4
21/7/2014 0:00,0.65,25.4
21/7/2014 0:00,0.67,25.3
21/7/2014 0:01,0.58,30.5
21/7/2014 0:01,0.54,26.7
21/7/2014 0:01,0.63,25.5
21/7/2014 0:01,0.65,26.9
21/7/2014 0:02,0.64,22.2
and this is a snippet of my code:
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+)')
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 = 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 ]
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('%d/%m/%Y %H:%M'))
ax1.plot(t, y, 'c', linewidth=3.3)
plt.show()
thanks