AmCholadawan

heat_map

Dec 28th, 2017
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.49 KB | None | 0 0
  1. import numpy as np
  2. import os
  3. import glob
  4. import matplotlib.pyplot as plt
  5.  
  6. path = '/Users/ammacpro1/simulation_results/self_energy_robot/test11/test11FiniteTroph/Bots25Boundary10Maxfood1000_2017-12-26000629243/plot_data/*Estored*txt'
  7. #path = '/Users/ammacpro1/AnacondaProjects/result_increase_initial_energy/Troph_UTLT_average/UT50LT20/InFiniteTroph/Bots25Boundary10Maxfood1000_2017-12-26000629243/plot_data/*Estored*txt'
  8. files = glob.glob(path)
  9.  
  10.  
  11. totalfrequency = np.zeros((28, 28), dtype=np.int8)
  12. totalenergy = np.zeros((28, 28), dtype=np.int8)
  13.  
  14. for file in files:
  15.     for line in open(file, 'r'):
  16.         robot = line.rstrip('\n').split(' ')
  17.         #robot = map(int, robot) #python2
  18.         robot = list(map(int, robot)) #python3
  19.         totalfrequency[robot[0], robot[1]] = totalfrequency[robot[0], robot[1]] + 1
  20.         totalenergy[robot[0], robot[1]] = totalenergy[robot[0], robot[1]] + robot[2]
  21.  
  22.  
  23. plt.matshow(totalfrequency, cmap='terrain_r', vmin = 0)
  24. plt.title('Frequency')
  25. plt.colorbar()
  26. #plt.matshow(totalenergy, cmap='hot', vmin = 0)
  27. #plt.title('Energy')
  28. #plt.colorbar()
  29. plt.show()
  30.  
  31.  
  32.  
  33.  
  34. #Energy
  35.  
  36. #total = np.zeros((100, 100), dtype=np.int8)
  37. #
  38. #for file in files:
  39. #    for line in open(file, 'r'):
  40. #        robot = line.rstrip('\n').split(' ')
  41. #        #robot = map(int, robot) #python2
  42. #        robot = list(map(int, robot)) #python3
  43. #        total[robot[0], robot[1]] = total[robot[0], robot[1]] + robot[2]
  44. #
  45. #
  46. #plt.matshow(total)
  47. #plt.colorbar()
  48. #plt.show()
Add Comment
Please, Sign In to add comment