maplotlib python 玩具绘图 横向纵向条状图

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')

  

转载于:https://www.cnblogs.com/SunshineKimi/p/11295564.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值