【发布时间】: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.
【问题讨论】:
-
如果您使用的是 Jupyter 笔记本:github.com/matplotlib/matplotlib/issues/18047
标签: python-3.x numpy matplotlib