matplotlib画图报错This figure includes Axes that are not compatible with tight_layout, so results might be incorrect.

之前用以下代码将实验结果用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()

嗯,,,是没设置画布和子图= =。。。

原文地址:https://www.cnblogs.com/peanutk/p/10784082.html

时间: 2024-07-31 03:00:31

matplotlib画图报错This figure includes Axes that are not compatible with tight_layout, so results might be incorrect.的相关文章

Anaconda3使用matplotlib画图报错问题的解决方法

在Anaconda3中使用matplotlib画图报错:ModuleNotFoundError: No module named 'PyQt4' 试了网上的几种方法都不奏效,最后在http://www.lfd.uci.edu/~gohlke/pythonlibs/#pyqt4 上下载和Python版本对应PyQt4的.whl文件,然后用pip命令安装. 此刻再执行程序不报上述错误,在执行到plt.figure()命令时又报:TypeError:'figure' is an unkown keyw

[Python]PyCharm中%matplotlib inline报错

%matplotlib作用 是在使用jupyter notebook 或者 jupyter qtconsole的时候,才会经常用到%matplotlib,也就是说那一份代码可能就是别人使用jupyter notebook 或者 jupyter qtconsole进行编辑的.关于jupyter notebook是什么,可以参考这个链接:[Jupyter Notebook介绍.安装及使用教程] 而%matplotlib具体作用是当你调用matplotlib.pyplot的绘图函数plot()进行绘图

matplotlib.pyplot import报错: ValueError: _getfullpathname: embedded null character in path

Environment: Windows 10, Anaconda 3.6 matplotlib 2.0 import matplotlib.pyplot 报错: ValueError: _getfullpathname: embedded null character in path 原因以及Solution: http://stackoverflow.com/questions/34004063/error-on-import-matplotlib-pyplot-on-anaconda3-f

解决mysql插入中文字符报错的问题ERROR 1366 (HY000): Incorrect string value: ‘\xE5\xB0\x8F\xE6\x98\x8E‘ for column ‘name‘ at row 1

原文:解决mysql插入中文字符报错的问题ERROR 1366 (HY000): Incorrect string value: '\xE5\xB0\x8F\xE6\x98\x8E' for column 'name' at row 1 报错内容: mysql> insert into person values (1,22,'小明');ERROR 1366 (HY000): Incorrect string value: '\xE5\xB0\x8F\xE6\x98\x8E' for colum

tensorflow读取jpg格式图片报错 ValueError: Only know how to handle extensions: ['png']; with Pillow installed matplotlib can handle more images

当运行mpimg.imread("img.jpg")时,spyder 出现如下错误: ValueError: Only know how to handle extensions: ['png']; with Pillow installed matplotlib can handle more images 解决办法就是  安装pillow即可 我是在anaconde里安装的很简单,执行如下步骤即可: tensorflow读取jpg格式图片报错 ValueError: Only kn

图文详解python之matplotlib安装与报错解决办法

说明: 首先python与matplotlib就不多介绍了,可以百度.个人也是第一次接触的小白,在安装过程中遇到一些较为难以理解的问题,通过努力解决后,在此做为例子分享出来. 工具包下载官网地址: python 下载官网 https://www.python.org/downloads/windows/ matplotlib 下载官网 https://pypi.org/project/matplotlib/#filesnumpy 下载官网 https://pypi.org/project/num

用python matplotlib 画图

state-machine environment object-oriente interface figure and axes backend and frontend user interface bankends hardcopy backends or non-interactive backends confugure your backends renderer : AGG import matplotlib.pyplot as plt plt.plot() 可一次画好几个, r

关于ECSHOP模板架设的服务器php版本过高报错的解决

1.admin/index.php admin/sms_url.php  ECSHOP模板 报错:Strict Standards: mktime(): You should be using the time() function instead in /data/web/ledetaoadmin/sms_url.php on line 31 $auth = mktime(); 替换为: $auth = time(); 报错:Strict Standards: Only variables s

ecshop后台支付方式的报错(2)

chinapay\netpayclient.php(2) : eval()'d code(1) :解决方法 在ecshop上安装银联支付的插件后,刷新返回支付方式,然而只要执行netpayclient.php文件就会报错: Fatal error: Cannot redeclare hex2bin() in /Applications/XAMPP/xamppfiles/htdocs/amf/includes/modules/payment/chinapay/netpayclient.php(2)