【问题标题】:UserWarning in matplotlibmatplotlib 中的用户警告
【发布时间】:2021-07-19 23:50:39
【问题描述】:

我正在尝试使用以下代码绘制图表:

import numpy as np
import matplotlib.pyplot as plt
arr = np.random.randint(1,50,10)
print(arr)
y, x = np.histogram(arr,bins=np.arange(51))
fig, ax = plt.subplots()
ax.plot(x[:-1],y)
fig.show()

显示的错误是:

<ipython-input-4-31fe4acba862>:8: UserWarning: Matplotlib is currently using module://ipykernel.pylab.backend_inline, which is a non-GUI backend, so cannot show the figure.

虽然我仍然得到一个图表:

【问题讨论】:

标签: python-3.x numpy matplotlib


【解决方案1】:

警告来自fig.show()。您可以在使用 jupyter 时将其删除。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-03-23
    • 1970-01-01
    • 2013-10-18
    • 2019-07-17
    • 1970-01-01
    • 1970-01-01
    • 2019-12-17
    • 2013-04-16
    相关资源
    最近更新 更多