Advertisement
Guest User

Untitled

a guest
Mar 30th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.92 KB | None | 0 0
  1. file_1 = open("datadict.txt")
  2. from collections import Counter
  3.  
  4. import matplotlib.pyplot as plt
  5.  
  6. ang_list = []
  7. cam_list = []
  8. est_list = []
  9. global_dic = {}
  10.  
  11. for line in file_1:
  12.     s = eval(line[line.index("{"):])
  13.  
  14.     key_ang = s["calls"]["Angola"]
  15.     ang_list.append(key_ang)
  16.     ang_final_count = Counter(ang_list)
  17.  
  18.     key_cam = s["calls"]["Cameroon"]
  19.     cam_list.append(key_cam)
  20.     cam_final_count = Counter(cam_list)
  21.  
  22.     key_est = s["calls"]["East"]
  23.     est_list.append(key_est)
  24.     est_final_count = Counter(est_list)
  25.  
  26. global_dic = {"Angola": ang_final_count, "Cameroon": cam_final_count, "East": est_final_count}
  27.  
  28. mpl_fig1 = plt.figure()
  29. ax = mpl_fig1.add_subplot(111)
  30. plt.bar(range(len(global_dic["Angola"])), global_dic["Angola"].values(), align="center")
  31. plt.xticks(range(len(global_dic["Angola"]), global_dic["Angola"].keys())
  32. ax.set_ylabel('nr')
  33. ax.set_xlabel('snp_distribution')
  34. lt.savefig("teste")
  35. print (global_dic)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement