Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- file_1 = open("datadict.txt")
- from collections import Counter
- import matplotlib.pyplot as plt
- ang_list = []
- cam_list = []
- est_list = []
- global_dic = {}
- for line in file_1:
- s = eval(line[line.index("{"):])
- key_ang = s["calls"]["Angola"]
- ang_list.append(key_ang)
- ang_final_count = Counter(ang_list)
- key_cam = s["calls"]["Cameroon"]
- cam_list.append(key_cam)
- cam_final_count = Counter(cam_list)
- key_est = s["calls"]["East"]
- est_list.append(key_est)
- est_final_count = Counter(est_list)
- global_dic = {"Angola": ang_final_count, "Cameroon": cam_final_count, "East": est_final_count}
- mpl_fig1 = plt.figure()
- ax = mpl_fig1.add_subplot(111)
- plt.bar(range(len(global_dic["Angola"])), global_dic["Angola"].values(), align="center")
- plt.xticks(range(len(global_dic["Angola"]), global_dic["Angola"].keys())
- ax.set_ylabel('nr')
- ax.set_xlabel('snp_distribution')
- lt.savefig("teste")
- print (global_dic)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement