热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

使用plt.show()时报错'ValueError:max()argisanemptysequence'

在Pycharm下使用matploylib库绘制3D图的时候,在最后需要显示图像的时候,每当输入

在Pycharm下使用matploylib库绘制3D图的时候,在最后需要显示图像的时候,每当输入

1
plt.show()

都会报错

1
ValueError: max() arg is an empty sequence

但是同样的代码在IDLE里面运行就没有问题。
请问是怎么回事儿呢?应该怎么处理才好,非常感谢

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import numpy as np

import matplotlib.pyplot as plt

from mpl_toolkits.mplot3d import Axes3D





x = np.linspace(-6 * np.pi, 6 * np.pi, 1000)

y = np.sin(x)

z = np.cos(x)





fig = plt.figure()

ax = Axes3D(fig)





ax.plot(x, y, z)





plt.show()

我试着在 Python Console 里一行一行的运行,都是在最后

1
plt.show()

的时候才会报错

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
[]

plt.show()

/Users/harry./Library/Python/3.6/lib/python/site-packages/matplotlib/figure.py:1743: UserWarning: This figure includes Axes that are not compatible with tight_layout, so its results might be incorrect.

  warnings.warn("This figure includes Axes that are not "

Traceback (most recent call last):

  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/IPython/core/interactiveshell.py", line 3267, in run_code

    exec(code_obj, self.user_global_ns, self.user_ns)

  File "", line 1, in

    plt.show()

  File "/Users/harry./Library/Python/3.6/lib/python/site-packages/matplotlib/pyplot.py", line 253, in show

    return _show(*args, **kw)

  File "/Applications/PyCharm.app/Contents/helpers/pycharm_matplotlib_backend/backend_interagg.py", line 27, in __call__

    manager.show(**kwargs)

  File "/Applications/PyCharm.app/Contents/helpers/pycharm_matplotlib_backend/backend_interagg.py", line 99, in show

    self.canvas.show()

  File "/Applications/PyCharm.app/Contents/helpers/pycharm_matplotlib_backend/backend_interagg.py", line 64, in show

    self.figure.tight_layout()

  File "/Users/harry./Library/Python/3.6/lib/python/site-packages/matplotlib/figure.py", line 1753, in tight_layout

    rect=rect)

  File "/Users/harry./Library/Python/3.6/lib/python/site-packages/matplotlib/tight_layout.py", line 326, in get_tight_layout_figure

    max_nrows = max(nrows_list)

ValueError: max() arg is an empty sequence

图片描述


推荐阅读
author-avatar
Kioone_818
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有