# coding: utf-8
# In[1]:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
# In[2]:
# :http://data.stats.gov.cn/search.htm?s=%E6%AF%95%E4%B8%9A%E7%94%9F
xls=pd.read_excel("d:/graduates.xls",index=False)
# In[3]:
header_names=xls[" "]
transformed_xls=xls.iloc[:,1:40].stack().unstack(0)
transformed_xls.columns = header_names
cleared_data=transformed_xls.sort_index(0,ascending=True)
y=cleared_data.iloc[:,0].tolist()
x=cleared_data.index.values.tolist()
x=list(map(lambda v:v[:4],x))
plt.rcParams['font.sans-serif'] = ['SimHei']
plt.rcParams['figure.figsize'] = (18, 9)
plt.rc('axes', axisbelow=True)
plt.grid(axis="y",alpha=0.5)
plt.xticks(rotation=45)
plt.bar(x,y,color="#FF6666")
plt.title(" ",fontsize=20)
plt.annotate(xy=(0,750),s=" : ",fontsize=10,color="#FF6666")
plt.annotate(xy=(18,750),s=" ≈ "+str(round(sum(y)))+" ",fontsize=10,color="#FF6666")
plt.xlabel(" ",fontsize=15)
plt.ylabel(" ( )",fontsize=15)
plt.savefig("d:/graduates.png")
plt.show()