import matplotlib.pyplot as plt from matplotlib import rcParams name_list_en = ['Computer Science', 'Physics', 'Mathematics' , 'Statistics' , 'Quantitative Biology', 'Quantitative Finance'] num_list = [8594, 6013, 5618, 5206, 587, 249] colors = ['green', 'yellow', 'blue', 'red'] # 设置字体类型新罗马体 config = { "font.family": 'Times New Roman', # "font.size": 80, # "mathtext.fontset":'stix', } rcParams.update(config) # 设置标题 # plt.title('Statistics of tags in coal mine datasets') # 控制x轴和y轴的范围 # plt.xlim(10, 20) # plt.ylim(10, 20) # 决定分割部分,及其与其它部分之间的间距 expl = [0, 0, 0.1, 0, 0, 0] patches, l_text, p_text = plt.pie(x=num_list, labels=name_list_en, rotatelabels=0, pctdistance=0.7, autopct='%3.1f %%', colors=colors, shadow=False) # 设置饼图内外字体大小 for t in p_text: t.set_size(10) for t in l_text: t.set_size(9.8) plt.show() # 保存 # plt.savefig('./public.pdf')