zoukankan      html  css  js  c++  java
  • Python数据可视化入门

    前言

    python可视化的模块是mtaplotlib,我们要使用它来生成统计图。

    示例

    import matplotlib.pyplot as plt
    import numpy as np
    
    #获取的参数
    plt.rcParams['font.sans-serif'] = ['KaiTi']
    labels = ['xx项目V1.0', 'xx项目V2.0']
    men_means = [47, 26]
    women_means = [12, 2]
    hui_gui = [4, 3]
    
    x = np.arange(len(labels))  # 标签位置
    width = 0.1  # 柱状图宽度
    
    fig, ax = plt.subplots()
    rects1 = ax.bar(x - width/2, men_means, width, label='BUG总数量')
    rects2 = ax.bar(x + width/2, women_means, width, label='严重BUG数量')
    rects3 = ax.bar((x + width/2) + width, hui_gui, width, label='回归次数')
    
    # 添加一些说明
    ax.set_ylabel('数量')
    ax.set_title('项目质量对比')
    ax.set_xticks(x)
    ax.set_xticklabels(labels)
    ax.legend()
    
    def autolabel(rects):
        """在柱状图上打上数字进行显示."""
        for rect in rects:
            height = rect.get_height()
            ax.annotate('{}'.format(height),
                        xy=(rect.get_x() + rect.get_width() / 2, height),
                        xytext=(0, 3),  # 3 points vertical offset
                        textcoords="offset points",
                        ha='center', va='bottom')
    
    autolabel(rects1)
    autolabel(rects2)
    autolabel(rects3)
    
    fig.tight_layout()
    plt.show()
    

  • 相关阅读:
    redhat5.5 x64 安装oracle 11g
    在Linux上搭建VisualSVN Server(svn服务端)
    执行impdp时出现的各种问题
    转: oracle中schema指的是什么?
    [NOIP2000] 乘积最大
    高精模板
    [NOIP2006]金明的预算方案
    luogu P1268 树的重量
    [NOIP2008]传纸条
    luogu P1522 Cow Tours
  • 原文地址:https://www.cnblogs.com/huny/p/14312747.html
Copyright © 2011-2022 走看看