from matplotlib import font_manager
#解决zh-han图形汉字乱码
my_font = font_manager.FontProperties(fname="C:/Windows/Fonts/simsun.ttc")
def draw_xmap(x_list,y_list):
""" daily map draw """
try:
import matplotlib.pyplot as plt1
except Exception as e:
print(e)
else:
plt1.figure(figsize=(14,10))
def autolabel(rects):
plt1.xlabel("项目名",fontproperties=my_font)
plt1.ylabel("项目组人力人均饱和度值",fontproperties=my_font)
plt1.xticks(fontproperties=my_font, fontsize=10,rotation=0)
for rect in rects:
height = rect.get_height()
plt1.text(rect.get_x()+rect.get_width()/2.- 0.2, 0.999*height, '%s' % height)
y_list.sort()
autolabel(plt1.bar(range(len(y_list)), y_list,color='#87CEFA',tick_label=x_list,width=0.4))
if os.path.exists(os.getcwd()+'\\pngdir'):
pass
else:
os.mkdir(os.getcwd()+"\\pngdir")
plt1.savefig('../toy/pngdir/daysara.png')
def draw_hmap(h_list,value_list):
value_list=[ float('%.3f' % i) for i in value_list]
""" week map draw """
try:
import numpy as np
import matplotlib.pyplot as plt
except Exception as e:
print(e)
else:
y_pos = np.arange(len(h_list))
value_list.sort()
plt.figure(figsize=(14,10))
reacts=plt.barh(y_pos, value_list, align='center',height=0.6)#这里是产生横向柱状图 barh h--horizontal
plt.yticks(y_pos, h_list,fontproperties=my_font, fontsize=10)
plt.xlabel('个人日均饱和度',fontproperties=my_font)
plt.ylabel("日均和度人员",fontproperties=my_font)
plt.xlim(0,2)
plt.title('RANK No.')
for index,x in enumerate(value_list):
for r in reacts:
plt.text(x,index-0.4/2,'%s' % x)
if os.path.exists(os.getcwd()+'\\pngdir'):
pass
else:
os.mkdir(os.getcwd()+"\\pngdir")
plt.savefig('../toy/pngdir/weeksara.png')