之前用以下代碼將實驗結果用matplotlib show出來
plt.plot(np.arange(len(aver_reward_list)), aver_reward_list)
plt.ylabel('Average Reward') plt.xlabel('Episode')
plt.tight_layout()
plt.savefig("AverageReward.eps")
plt.show()
畫出的圖都沒什么問題,但忽然有一次數據量比較大,matplotlib開始報錯,並且畫出的圖出現以下問題:
報錯:
D:\softwares\coding\Python\Python3.6\lib\site-packages\matplotlib\figure.py:2359: UserWarning: This figure includes Axes that are not compatible with tight_layout, so results might be incorrect. warnings.warn("This figure includes Axes that are not compatible "
圖:
看到坐標軸丟失,並且坐標都擠到一起了,先想到的會不會是數據太多軸坐標密集給擠一起了?
= = too stupid… matplotlib當然會管理好坐標密度的。
然后又看了下matplotlib畫圖的標准代碼,才知道問題出在哪里:
plt.figure() plt.subplot(111) plt.plot(np.arange(len(ep_reward_list)), ep_reward_list) plt.xlabel('episode') plt.ylabel('ep_reward') plt.savefig('RL_%s.png' % MAX_EPISODES) plt.show()
嗯,,,是沒設置畫布和子圖= =。。。