Project 2 for MA132
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
603 B

  1. #!/usr/bin/python3
  2. import pylab
  3. import os
  4. files = sorted(os.listdir("data/"))
  5. simulations = {}
  6. for file in files:
  7. population = []
  8. with open("data/" + file, "r") as f:
  9. for line in f.readlines():
  10. population.append(int(line.split()[1]))
  11. simulations.update({file.strip(".dat"): population})
  12. print(simulations.keys())
  13. t = pylab.arange(1, 3649, 1)
  14. for key in simulations.keys():
  15. s = [i**2 for i in simulations[key]]
  16. pylab.plot(t, s, color="purple")
  17. pylab.xlabel('Days')
  18. pylab.ylabel('Population')
  19. pylab.title('Stink Bug Population')
  20. pylab.grid(True)
  21. pylab.show()