[Python] matplotlib으로 그림그리고 저장하기 (savefig)

이향기·2023년 1월 26일
0
import matplotlib.pyplot as plt

fig, (ax0,  ax1) = plt.subplots(2, figsize=(9, 8))
fig.suptitle('super title을 입력하세요')
ax01=ax0.twinx()
ax0.plot(x, y, marker='o')
ax01.plot(x, y, color='tab:orange', marker='o')
ax0.set_title('sub title을 입력하세요')
ax0.set_xticks(tick_location, labels=ticks_label) #, rotation=45)
ax0.set_ylabel("Year effects")
ax01.set_ylabel("KOSPI")
ax0.grid(True)
        
ax11=ax1.twinx()
ax1.plot(x, y, marker='o')
ax11.plot(x, y, color='tab:orange', marker='o')
ax1.set_title('sub title을 입력하세요')
ax1.set_xticks(tick_location, labels=ticks_label) #, rotation=45)
ax1.set_ylabel("Earinings (Year)")
ax11.set_ylabel("KOSPI")
ax1.grid(True)
fig.tight_layout()
plt.savefig(f'{plot_path}/{jc}_{jobname}({sexname}).png')
# plt.show()
plt.close()
profile
Data science & Machine learning, baking and reading(≪,≫)

0개의 댓글