matplotlib에서 동일한 종횡비 그림의 모서리에 텍스트를 배치하려면 다음 단계를 수행할 수 있습니다. -
-
Figure 크기를 설정하고 서브플롯 사이와 주변의 패딩을 조정합니다.
-
subplots()를 사용하여 Figure와 서브플롯 세트 생성 방법.
-
numpy를 사용하여 x 데이터 포인트를 만듭니다.
-
plot()을 사용하여 축 x1에 플롯 x 방법.
-
plot()을 사용하여 x 및 2*x를 ax2에 플롯 방법.
-
그림 모서리에 텍스트를 넣으려면 annotate()를 사용하세요. 다른 축에 대한 방법.
-
그림을 표시하려면 show()를 사용하세요. 방법.
예시
from matplotlib import pyplot as plt
plt.rcParams["figure.figsize"] = [7.50, 3.50]
plt.rcParams["figure.autolayout"] = True
fig, axes = plt.subplots(2)
x = np.linspace(-2, 2, 10)
axes[0].plot(x)
axes[1].plot(x, 2*x)
for ax in axes:
ax.annotate('Straight Line', xy=(1, 0),xycoords='axes fraction', fontsize=10, horizontalalignment='right', verticalalignment='bottom')
plt.show() 출력
