1 # 直方图 bins指定直方图条数,edgecolor指定直方图的边框色
2 plt.figure(figsize=(9, 24))
3 # fig, ax = plt.subplots(9, 100)
4 # data.plot(kind = 'hist', bins = 20, color = 'blue', edgecolor = 'black', density = True, label = '直方图')
5
6 '''
7 plt.bar(list(dict_au.keys()), list(dict_au.values()), width=0.9, color='lightsteelblue', label='频次直方图')
8 #plt.plot(range(51), list(dict_au.values()), marker = 'o', color = 'coral') #coral
9 plt.xticks(list(dict_au.keys()), rotation=80)
10 # 密度图
11 #data.plot(kind = 'kde', color = 'red', label = '核密度图')
12
13 plt.xlabel('作者名Name', fontdict={'weight':'normal','size': 12})
14 plt.ylabel('频次Num', fontdict={'weight':'normal','size': 12})
15
16 plt.ylim(0, 4) # y轴取值范围
17 ax=plt.gca()
18 y_major_locator = plt.MultipleLocator(1) # 调整间隔为1
19 ax.yaxis.set_major_locator(y_major_locator)
20
21 plt.title('作者出现频次统计', fontdict={'weight':'bold','size': 16})
22 '''
23
24 '''
25 plt.bar(list(dict_co.keys()), list(dict_co.values()), width=0.9, color='lightsteelblue', label='频次直方图')
26 plt.xticks(list(dict_co.keys()), rotation=80)
27 plt.xlabel('国家Country', fontdict={'weight':'normal','size': 12})
28 plt.ylabel('频次Num', fontdict={'weight':'normal','size': 12})
29 plt.ylim(0, 33) # y轴取值范围
30 ax=plt.gca()
31 y_major_locator = plt.MultipleLocator(2) # 调整间隔为1
32 ax.yaxis.set_major_locator(y_major_locator)
33 plt.title('作者所在国家频次统计', fontdict={'weight':'bold','size': 16})
34 '''
35
36 '''
37 plt.bar(list(dict_unit.keys()), list(dict_unit.values()), width=0.9, color='lightsteelblue', label='频次直方图')
38 plt.xticks(list(dict_unit.keys()), rotation=80)
39 plt.xlabel('单位Unit', fontdict={'weight':'normal','size': 12})
40 plt.ylabel('频次Num', fontdict={'weight':'normal','size': 12})
41 plt.ylim(0, 7) # y轴取值范围
42 ax=plt.gca()
43 y_major_locator = plt.MultipleLocator(1) # 调整间隔为1
44 ax.yaxis.set_major_locator(y_major_locator)
45 plt.title('作者所在单位频次统计', fontdict={'weight':'bold','size': 16})
46 '''
47
48 r_list = [255, 123, 223, 167, 32]
49 g_list = [218, 222, 99, 245, 230]
50 b_list = [185, 173, 71, 238, 250]
51
52 plt.bar(list(dict_unit.keys()), co_dict[1], width=0.8, color=(255/255, 105/255, 185/255), label=list(dict_co.keys())[0])
53
54 for i in range(2, len(co_dict.keys()) + 1):
55 plt.bar(list(dict_unit.keys()), co_dict[i], width=0.8, color=(r_list[i-2]/255, g_list[i-2]/255, b_list[i-2]/255),
56 bottom=co_dict[i-1], label=list(dict_co.keys())[i-1])
57
58 plt.xticks(list(dict_unit.keys()), rotation=80)
59 plt.xlabel('所在单位', fontdict={'weight': 'normal', 'size': 12})
60 plt.ylabel('数量Num', fontdict={'weight': 'normal', 'size': 12})
61 plt.ylim(0, 7) # y轴取值范围
62 ax = plt.gca()
63 y_major_locator = plt.MultipleLocator(1) # 调整间隔为1
64 ax.yaxis.set_major_locator(y_major_locator)
65 plt.title('所有单位的作者所在国家分布', fontdict={'weight': 'bold', 'size': 16})
66
67 plt.subplots_adjust(left=0.1, bottom=0.3, right=0.9, top=0.9, hspace=1, wspace=1) # 调整显示大小,左和下为边界,右和上为大小
68
69 plt.legend()
70
71 plt.savefig("result.png", format='png')
72 plt.show()