python max() arg is empty_使用plt.show()时报错 'ValueError: max() arg is an empty sequence'

在Pycharm下使用matploylib库绘制3D图的时候,在最后需要显示图像的时候,每当输入plt.show() 都会报错

ValueError: max() arg is an empty sequence

但是同样的代码在IDLE里面运行就没有问题。

请问是怎么回事儿呢?应该怎么处理才好,非常感谢

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 里一行一行的运行,都是在最后plt.show()的时候才会报错

[]

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值