zoukankan      html  css  js  c++  java
  • matplotlib----初探------4条形图

    概念

    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

    以长方形的长度为变量的统计图表
    用来比较多个项目分类的数据大小
    通常利用于较小的数据集分析
    例如不同季度的销量,不同国家的人口等

    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

    简单的例子
    参数调整 -  height, width, bottom, color, orientation
    并列条形图 VS 层叠条形图

    import numpy as np
    import matplotlib.pyplot as plt
    N=5
    y=[20,10,30,25,15]
    index = np.arange(N)
    p1 = plt.bar(index, height=y,width=0.5,bottom=100,color='red')
    plt.show()

    》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》

    import numpy as np
    import matplotlib.pyplot as plt
    N=5
    y=[20,10,30,25,15]
    index = np.arange(N)
    p2 = plt.bar(0, bottom=index, width=y,height=0.5,orientation='horizontal')
    plt.show()

    》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》》

    两栏:

    import numpy as np
    import matplotlib.pyplot as plt
    N=5
    y=[20,10,30,25,15]
    index = np.arange(N)
    index=np.arange(4)
    sales_BJ=[52,55,63,53]
    sales_SH=[44,66,55,41]
    bar_width=0.3
    plt.bar(index,sales_BJ,bar_width,color='b')
    plt.bar(index+bar_width,sales_SH,bar_width,color='r')
    plt.show()

    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

    import numpy as np
    import matplotlib.pyplot as plt
    N=5
    y=[20,10,30,25,15]
    index = np.arange(N)
    index=np.arange(4)
    sales_BJ=[52,55,63,53]
    sales_SH=[44,66,55,41]
    bar_width=0.3
    plt.bar(index,sales_BJ,bar_width,color='b')
    plt.bar(index,sales_SH,bar_width,color='r',bottom=sales_BJ)
    plt.show()

  • 相关阅读:
    Construction构造函数
    映射验证
    映射设置
    条件映射
    映射前和映射后的操作
    AutoMapper 5.0-升级指南
    Bootstrap Tree View
    MiniProfiler使用笔记
    关于添加数据自定义编号格式问题
    【Postgresql】数据库函数
  • 原文地址:https://www.cnblogs.com/dushuhubian/p/10296467.html
Copyright © 2011-2022 走看看