如何增加matplotlib“table”绘图的高度

2024-09-19 23:38:49 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图在matplotlib中绘制一些表格,但是对于supblot,在这种情况下,表格高度太小,如何用表格填充较低的supblot

问题:第二行表格子批次高度太小,如何增加其高度

MWE

import numpy as np
import matplotlib.pyplot as plt

fig,ax = plt.subplots(2,1,figsize=(24,28))

# buy
ax[0].bar([1,2,3,4,5],[100,200,300,400,500])
ax[0].tick_params(axis='both', which='major', labelsize=18)

# table
colors = list('rrrbb')
ax[1].table(cellText=list('abcde'),
            rowLabels=list('abcde'),
            loc='center',
            rowColours=colors,
            cellColours=np.array(colors).reshape(-1,1))

enter image description here


Tags: import高度matplotlibasnptable绘制plt
1条回答
网友
1楼 · 发布于 2024-09-19 23:38:49
fig,ax = plt.subplots(2,1,figsize=(14, 14))

# buy
ax[0].bar([1,2,3,4,5],[100,200,300,400,500])
ax[0].tick_params(axis='both', which='major', labelsize=18)

# table
colors = list('rrrbb')
table = ax[1].table(cellText=list('abcde'),
            rowLabels=list('abcde'),
            loc='center',
            rowColours=colors,
            cellColours=np.array(colors).reshape(-1,1))

ax[1].set_title('Scale (1, 4)')

table.scale(1, 4)

比额表(1,4)

enter image description here

比例(1,1)

enter image description here

相关问题 更多 >