zoukankan      html  css  js  c++  java
  • matplotlib绘制表格

    #-----例子1---------------------------------------------
    import matplotlib.pyplot as plt
    
    data = [[1,2,3,4],[6,5,4,3],[1,3,5,1]]
    
    table = plt.table(cellText=data, colLabels=['A', 'B', 'C', 'D'], loc='center',
                      cellLoc='center', colColours=['#FFFFFF', '#F3CC32', '#2769BD', '#DC3735'])
    table.auto_set_font_size(False)
    h = table.get_celld()[(0,0)].get_height()
    w = table.get_celld()[(0,0)].get_width()
    
    # Create an additional Header
    header = [table.add_cell(-1,pos, w, h, loc="center", facecolor="none") for pos in [1,2,3]]
    header[0].visible_edges = "TBL"
    header[1].visible_edges = "TB"
    header[2].visible_edges = "TBR"
    header[1].get_text().set_text("Header Header Header Header")
    
    plt.axis('off')
    plt.show()
    #-----例子2---------------------------------------------
    import matplotlib.pyplot as plt
    import numpy as np
    
    plt.figure()
    ax = plt.gca()
    
    y = np.random.randn(9)
    col_labels = ['col1','col2','col3']
    row_labels = ['row1','row2','row3']
    table_vals = [[11,12,13],[21,22,23],[28,29,30]]
    row_colors = ['red','gold','green']
    my_table = plt.table(cellText=table_vals, colWidths=[0.1]*3, rowLabels=row_labels, colLabels=col_labels, rowColours=row_colors, colColours=row_colors, loc='best')
    
    plt.plot(y)
    
    plt.show()
  • 相关阅读:
    ES6相关概念及新增语法
    正则表达式
    递归
    高阶函数和闭包
    严格模式
    this指向
    递归
    严格模式
    函数内部的this指向
    函数的定义和调用
  • 原文地址:https://www.cnblogs.com/muyue123/p/15176034.html
Copyright © 2011-2022 走看看