当前位置: 代码迷 >> 综合 >> This figure includes Axes that are not compatible with tight_layout, so results might be incorrect.
  详细解决方案

This figure includes Axes that are not compatible with tight_layout, so results might be incorrect.

热度:102   发布时间:2023-11-19 20:32:35.0

困难,是智者的机遇,是人与人差距所在。


疑惑

D:\pytools\anaconda\PyCharm 2018.3.5\helpers\pycharm_matplotlib_backend\backend_interagg.py:62: UserWarning: This figure includes Axes that are not compatible with tight_layout, so results might be incorrect.
  self.figure.tight_layout()

解惑

对照如下可以显示图形的代码,看看是不是哪里没有设置

from matplotlib import pyplot as plt
import numpy as np
x1 = np.linspace(1, 10, 20)##开始值是1,结束值是20,生成序列的个数为20个
y1 = x1 * x1 + 2
plt.figure()##创建一个图形对象
plt.subplot(111)##创建一个子图,行列
plt.plot(x1, y1, 'r')
plt.xlabel('episode')
plt.ylabel('ep_reward')
plt.savefig('tjn.png',bbox_inches='tight')##保存图片
plt.show()

 

  相关解决方案