在PyCharm中使用plt.show()时'ValueError:max()arg为空序列'

时间:2019-05-21 13:46:40

标签: python-3.x matplotlib pycharm

enter image description here我正在学习如何使用python绘制一些3D图片。 当我输入plt.show()时,会出现错误。

ValueError: max() arg is an empty sequence

但是,我尝试在IDLE上运行它,但没有错误。 使用PyCharm时应该如何解决此问题,非常感谢您的帮助。

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控制台中尝试过,只有运行plt.show()时才会出现错误。

[<mpl_toolkits.mplot3d.art3d.Line3D at 0x111b09c88>]
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 "<ipython-input-6-1eb00ff78cf2>", line 1, in <module>
    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 个答案:

没有答案