fork download
  1. import numpy as np
  2. import matplotlib.pyplot as plt
  3.  
  4. def scatterFile(file, what, color):
  5. d = np.loadtxt(file, skiprows=1, delimiter=',')
  6.  
  7. # arrange data
  8. sec = []
  9. vals = []
  10. for i in range(0, len(d)):
  11. # take a single second
  12. sec.append(d[i][0])
  13. # take the avarage of values for that second
  14. vals.append( np.average([d[i,j] for j in range(1,201)]) )
  15. print(sec)
  16. print(vals)
  17.  
  18. # show data on plot
  19. plt.scatter(sec,vals,'r')
  20.  
  21.  
  22. # Main:
  23. def main():
  24. title = 'Concentration of g_i (red) and r_i (blue)'
  25. plt.title(title)
  26. plt.xlabel('time (s)')
  27.  
  28. file = 'g_internal.csv'#'prova.csv'
  29. what = 'g_i'
  30. color = 'r'
  31. scatterFile(file,what,color)
  32.  
  33. file = 'r_internal.csv'#'prova.csv'
  34. what = 'r_i'
  35. color = 'b'
  36. scatterFile(file,what,color)
  37. plt.show()
  38. print("done")
Success #stdin #stdout 0.6s 49988KB
stdin
Standard input is empty
stdout
Standard output is empty