Matplotlib에서 "Times New Roman" 폰트를 사용하면서 제목을 굵게 표시하려면 fontweight="bold" 옵션을 활용하면 됩니다.
구현 단계
- 그림(figure) 크기를 설정하고 서브플롯 주변 및 사이의 패딩을 조정합니다.
- figure와 서브플롯 세트를 생성합니다.
- numpy를 사용하여 x, y 데이터 포인트를 생성합니다.
- scatter() 메서드를 사용하여 x, y 데이터 포인트를 산점도로 시각화합니다.
- fontname="Times New Roman"과 fontweight="bold" 옵션을 지정하여 플롯의 제목을 설정합니다.
- show() 메서드를 호출하여 그림을 화면에 출력합니다.
예제 코드
import numpy as np
from matplotlib import pyplot as plt, font_manager as fm
plt.rcParams["figure.figsize"] = [7.50, 3.50]
plt.rcParams["figure.autolayout"] = True
fig, ax = plt.subplots()
x = np.random.rand(100)
y = np.random.rand(100)
ax.scatter(x, y, c=y, marker="v")
ax.set_title('Scatter Plot With Random Points', fontname="Times New Roman", size=28,fontweight="bold")
plt.show()실행 결과

위 코드를 실행하면 Times New Roman 폰트가 적용되고 28pt 크기의 굵은 제목이 산점도 상단에 표시됩니다. 제목의 크기는 size 매개변수로, 굵기는 fontweight 매개변수로 자유롭게 조절할 수 있습니다.