How do I plot only a table in Matplotlib?

前端 未结 4 701
北荒
北荒 2020-11-27 05:16

Is it possible to draw only a table with matplotlib? If I uncomment the line

plt.bar(index, data[row], bar_width, bottom=y_offset, color=colors[row])
         


        
4条回答
  •  死守一世寂寞
    2020-11-27 05:51

    Not sure if this is already answered, but if you want only a table in a figure window, then you can hide the axes:

    fig, ax = plt.subplots()
    
    # Hide axes
    ax.xaxis.set_visible(False) 
    ax.yaxis.set_visible(False)
    
    # Table from Ed Smith answer
    clust_data = np.random.random((10,3))
    collabel=("col 1", "col 2", "col 3")
    ax.table(cellText=clust_data,colLabels=collabel,loc='center')
    

提交回复
热议问题