zoukankan      html  css  js  c++  java
  • python第三方库之matplotlib基本图形之条形图2

    Matplotlib基本图形之条形图2

    1.绘制多条条形图

    示例代码:

    import time
    import numpy as np
    import matplotlib.pyplot as plt
    
    
    basedir = os.path.dirname(os.path.abspath(__file__))
    resultdir = os.path.join(basedir, 'result')
    
    index = np.arange(4)
    A = [34,64,45,73]
    B = [44,53, 49,69]
    bar_width = 0.3
    plt.bar(index,A,bar_width,color='b')
    plt.bar(index+bar_width,B,bar_width,color='r')
    plt.savefig(os.path.join(resultdir,'test.png'))

    运行结果:

    2.绘制叠加条形图

     示例代码:

    import os
    import time
    import numpy as np
    import matplotlib.pyplot as plt
    import matplotlib.dates as mdates
    
    
    basedir = os.path.dirname(os.path.abspath(__file__))
    resultdir = os.path.join(basedir, 'result')
    
    index = np.arange(4)
    A = [34,64,45,73]
    B = [44,53, 49,69]
    bar_width = 0.3
    plt.bar(index,A,bar_width,color='b')
    plt.bar(index,B,bar_width,color='r',bottom=A)
    plt.savefig(os.path.join(resultdir,'test.png'))

    运行结果:

  • 相关阅读:
    LESS的简单介绍
    实例化对象的过程
    原生的AJAX
    http基础
    display的属性值测试
    js中arguments的简单用法
    JS数组控制台排序
    js中使用switch的语法结构和意义
    js入门—控制台输出console.log
    css入门—position详解
  • 原文地址:https://www.cnblogs.com/Keys819/p/9306991.html
Copyright © 2011-2022 走看看