zoukankan      html  css  js  c++  java
  • 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')

      

  • 相关阅读:
    开篇词The Start以及[Vjudge][HDU2242]空调教室
    [故地重游][NOIP2019]格雷码
    关于非触
    致诸君
    三角形的概率
    [HDU5970] 最大公约数
    [51Nod1534] 棋子游戏
    [TJOI2018] 数学计算
    [CF938D] Buy a Ticket
    [HDU4143] A Simple Problem
  • 原文地址:https://www.cnblogs.com/SunshineKimi/p/11295564.html
Copyright © 2011-2022 走看看