• matplotlib 柱状图 Bar Chart 样例及参数


    def bar_chart_generator():
        l = [1,2,3,4,5]
        h = [20, 14, 38, 27, 9]
        w = [0.1, 0.2, 0.3, 0.4, 0.5]
        b = [1,2,3,4,5]
     
        fig = plt.figure()
        ax = fig.add_subplot(111)
        rects = ax.bar(l, h, w, b,
                       color='#ffff00',
                       edgecolor='#000000',
                       linewidth=2,
                       #xerr=4,
                       #yerr=1,
                       #ecolor='#999999',
                       #capsize=10,
                       #align='center',
                       #orientation='horizontal',
                      )
        plt.savefig('bar.png')
    ==================================
     
    函数原型:
    matplotlib.pyplot.bar(left, height, width=0.8, bottom=None, hold=None, **kwargs)
     
    基本参数:
    left        每个柱x轴左边界
    bottom      每个柱y轴下边界
    height      柱高度(Y轴方向) 
    width       柱宽度(X轴方向)
    以上参数可以设置为数值或者list
    但要保证如果为list, len(list)要一致
    绘制的方形为:
        X: left   --- left+width
        Y: bottom --- bottom+height
    返回值:
        matplotlib.patches.Rectangle
     
    柱状图使用bottom扩展即可化为甘特图 Gantt Chart
     
    其他参数:
    color       Bar颜色
    edgecolor   Bar边界线颜色
    align       可选['left'(default) | 'center']
                决定整个bar图分布
                默认left表示默认从左边界开始绘制,center会将图绘制在中间位置
     
    xerr        x方向error bar
    yerr        y方向error bar
    ecolor      error bar颜色
    capsize     error bar横线宽度(default 3)
     
    样例:
    基本设置
    l = [1,2,3,4,5]
    h = [20, 14, 38, 27, 9]
    w = [0.1, 0.2, 0.3, 0.4, 0.5]
    b = [1,2,3,4,5]
    matplotlib <wbr>柱状图 <wbr>Bar <wbr>Chart <wbr>样例及参数
    设置xerr=4
    matplotlib <wbr>柱状图 <wbr>Bar <wbr>Chart <wbr>样例及参数
    设置yerr=1,ecolor='#999999'
    matplotlib <wbr>柱状图 <wbr>Bar <wbr>Chart <wbr>样例及参数
     
    转载至 http://blog.sina.com.cn/s/blog_b09d4602010194wy.html
  • 相关阅读:
    Win10安装组策略功能
    IIS 站点批量迁移
    MongoDB 异常记录
    微信Web开发者工具
    NHibernate 异常
    Git 常用命令
    IIS 反向代理
    CSS应用
    Oracle
    Android之ActionBar学习
  • 原文地址:https://www.cnblogs.com/linyujin/p/9895328.html
Copyright © 2020-2023  润新知