3x2 행 - 열의 6 개 이미지로 된 A4 용지에 몇 가지 인덱스 데이터를 플로팅합니다. 기본 코드가 작동하고 있으며이 데이터 프레임 데이터를 다음 6 개의 플롯에 표시합니다.matplotlib의 정확한 서브 구조 크기 조정
def plot_idx(df,image,key):
# reset the default parameters
plt.rcParams['font.size'] = 8.
plt.rcParams['figure.figsize'] = (8.267, 11.692) #aA paper
fig = plt.figure()
#plot all the 6 figures and save the 3x2 image as png
ax1 = fig.add_subplot(321) # first row first image
#compute all time
alltime = df['Close'].count()
x,y,x_min, y_min, x_max, y_max = min_max(df,alltime)
ax1.plot(x, y,'r')
ax1.plot(x_min,y_min,'o')
ax1.plot(x_max,y_max,'o')
ax1.set_xlabel('year')
ax1.set_ylabel('Index Close')
ax1.set_title(plot_title[-1])
ax1.fill_between(x,y,facecolor='red')
ax1.annotate(y_min, xy=(x_min,y_min), xytext=(x_min,y_min +250))
ax1.annotate(y_max, xy=(x_max,y_max), xytext=(x_max,y_max +250))
ax2 = fig.add_subplot(322) # first row second image
# compute ytd
ytd = df.ix[baseline_year:]['Close'].count()
x,y,x_min, y_min, x_max, y_max = min_max(df,ytd)
ax2.plot(x, y,'r')
....
# repeat 4 more times for other figs
fig.suptitle(key, fontsize=10)
plt.tight_layout()
plt.savefig(image)
은 어떻게 제목 상단에 공간이 조금로 A4/6 동일한 크기 플롯으로 줄거리를받을 수 있나요? 8.267/2 x 11.69/3 크기에서와 같이? tight_layout은 도움이되지만 크기와 게재 위치를보다 효과적으로 제어하고 싶습니다. 당신이 더 많은 제어를 원하는 경우
내 대답이 문제를 해결 했습니까? – tacaswell