python-3.x - matplotlib 中的用户警告
问题描述
我正在尝试使用以下代码绘制图表:
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.
解决方案
警告来自fig.show()
. 您可以在使用 jupyter 时将其删除。
推荐阅读
- python-3.x - 在 tensorflow.keras 中使用经过训练的模型进行预测时的形状错误
- google-apps-script - 如何使用谷歌脚本中的 URL 参数过滤列谷歌表格中的数据?
- solr - Apache Solr cat:iphone^2 name:iphone^2 是什么意思?
- pytorch - Pytorch CNN:RuntimeError: 给定组=1,大小为 [16, 16, 3] 的权重,预期输入 [500, 1, 19357] 有 16 个通道,但有 1 个通道
- sockets - SSL:使用 Google Cloud 的 SSL 负载平衡代理的 UNKNOWN_PROTOCOL
- java - 当我单击android中的按钮时,我想一个接一个地播放音频
- android - 首次安装后应用程序屏幕变为空白(无法从设备获取文件夹)
- javascript - 搜索后无法拖动标记,传单地图
- python - 使用flask和wtforms在单个页面中的多个提交按钮
- python - 在新的 oEmbed Instagram API 中找不到 media_id 字段