如何在 Matplotlib 中更改現有表格的尺寸?
要改變表格的尺寸,我們可以使用 scale() 方法。步驟 -
建立一個圖形和一組子圖,nrows=1 和 ncols=1。
使用 numpy 建立隨機資料。
建立列值。
使軸緊和關閉。
初始化變數 fontsize 來改變 fontsize。
要設定表格的字型大小並縮放表格,我們可以使用 1.5 和 1.5。
要顯示圖形,使用 show() 方法。
示例
import numpy as np
from matplotlib import pyplot as plt
plt.rcParams["figure.figsize"] = [7.50, 3.50]
plt.rcParams["figure.autolayout"] = True
fig, axs = plt.subplots(1, 1)
data = np.random.random((10, 3))
columns = ("Column I", "Column II", "Column III")
axs.axis('tight')
axs.axis('off')
fontsize = 10
the_table = axs.table(cellText=data, colLabels=columns, loc='center')
the_table.set_fontsize(fontsize)
the_table.scale(1.5, 1.5)
plt.show()輸出

廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP