Guest User

Untitled

a guest
Jul 4th, 2015
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.17 KB | None | 0 0
  1. import matplotlib.pyplot as plt
  2. import numpy as np
  3. import sys
  4. from time_stats import get_times_map, seconds_to_time
  5.  
  6.  
  7. MIN_TIME = 60
  8. MAX_TIME = 160
  9. STEP_SIZE = 4
  10.  
  11.  
  12. def plot(times):
  13.     bins = range(MIN_TIME, MAX_TIME + STEP_SIZE, STEP_SIZE)
  14.     labels = [seconds_to_time(bin_seconds) for bin_seconds in bins]
  15.     ax = plt.subplot(111)
  16.     plt.hist(times, bins=bins, label=labels)
  17.     ax.set_xticks(bins)
  18.     ax.set_xticklabels(labels, rotation=45)
  19.     plt.ylabel('Kills (total: %s)' % (len(times)))
  20.     plt.xlabel('Time (average %s, median %s, stddev %s, min %s, max %s)' % (
  21.         seconds_to_time(np.mean(times)),
  22.         seconds_to_time(np.median(times)),
  23.         seconds_to_time(np.std(times)),
  24.         seconds_to_time(min(times)),
  25.         seconds_to_time(max(times)),
  26.     ))
  27.     hist = plt.gcf()
  28.     plt.show()
  29.     hist.savefig('histogram_zulrah.png', bbox_inches='tight')
  30.  
  31. def plot_times(filename):
  32.     times_map = get_times_map(filename)
  33.     time_list = times_map[times_map.keys()[0]]
  34.     plot(time_list)
  35.  
  36. if __name__=='__main__':
  37.     if len(sys.argv) != 2:
  38.         print 'Usage: plot_times.py [input file]'
  39.     else:
  40.         plot_times(sys.argv[1])
Advertisement
Add Comment
Please, Sign In to add comment