matplotlib를 사용하여 테이블의 글꼴 크기를 변경하려면 set_fontsize()를 사용할 수 있습니다. 방법.
단계
- 그림 및 서브플롯 세트 생성, nrows=1 및 ncols=1 .
- numpy를 사용하여 임의의 데이터 생성
- 열 만들기 가치.
- 축을 단단하게 만듭니다. 및 꺼짐 .
- 변수 글꼴 크기 초기화 글꼴 크기를 변경합니다.
- set_font_size()를 사용하여 표의 글꼴 크기 설정 방법.
- 그림을 표시하려면 show()를 사용하세요. 방법.
예시
import numpy as np
from matplotlib import pyplot as plt
plt.rcParams["figure.figsize"] = [7.00, 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')
the_table = axs.table(cellText=data, colLabels=columns, loc='center')
the_table.auto_set_font_size(False)
the_table.set_fontsize(10)
plt.show() 출력
