赞
踩
22届学长考研信息分析
# _*_coding:utf-8_*_ # create by Jucw on 2022/5/17 19:22 import xlrd import matplotlib.pyplot as plt plt.rcParams['font.sans-serif'] = ['SimHei'] plt.rcParams['axes.unicode_minus'] = False li = [] dic = {} key_list = [] value_list = [] x = xlrd.open_workbook("18yan.xlsx") table = x.sheet_by_name("Sheet0") # 修改列 cols = table.col(3) l = len(cols) for i in range(1,l): li.append((cols[i].value)) for i in li: if li.count(i)>=1: dic[i] = li.count(i) dic= sorted(dic.items(), key=lambda d:len(d[0]), reverse = True) for k,v in dic: key_list.append(k) value_list.append(v) print (key_list,value_list) plt.axes(aspect='equal') plt.pie(x = value_list, labels=key_list, autopct='%.1f%%', pctdistance=0.8, labeldistance = 1.2, startangle = 207, radius = 1.2, counterclock = False, wedgeprops = {'linewidth': 1.5, 'edgecolor':'red'}, textprops = {'fontsize':9, 'color':'black'}, ) plt.title('22届计算机考研院校',x=1,y=-0.1,color="red") plt.show()
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。