Skip to content

Instantly share code, notes, and snippets.

@anirudhjayaraman
Last active October 22, 2015 08:12
Show Gist options
  • Save anirudhjayaraman/ece6215e119d03415464 to your computer and use it in GitHub Desktop.
Save anirudhjayaraman/ece6215e119d03415464 to your computer and use it in GitHub Desktop.
List Manipulation Without NumPy
import pylab
def loadfile():
inFile = open('julyTemps.txt', 'r')
high =[]; low = []
for line in inFile:
fields = line.split()
if len(fields) < 3 or not fields[0].isdigit():
pass
else:
high.append(int(fields[1]))
low.append(int(fields[2]))
return low, high
def producePlot(lowTemps, highTemps):
diffTemps = [highTemps[i] - lowTemps[i] for i in range(len(lowTemps))]
pylab.title('Day by Day Ranges in Temperature in Boston in July 2012')
pylab.xlabel('Days')
pylab.ylabel('Temperature Ranges')
return pylab.plot(range(1,32),diffTemps)
producePlot(loadfile()[1], loadfile()[0])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment