【发布时间】:2016-10-25 04:48:19
【问题描述】:
我尝试运行 plt.show() 但没有显示任何情节。我尝试了很多来自 stackoverflow 的解决方案,包括将 matplotlib 后端设置为 Qt4Agg、切换到其他后端(即 TkAgg、Agg)以及重新安装 matplotlib 包,但仍然没有解决问题。我尝试过但不起作用的一些解决方案是:
matplotlib does not show my drawings although I call pyplot.show()
Matplotlib.Pyplot does not show output; No Error
Matplotlib does not show labels or numbers
下面是我尝试运行的代码:
plt.scatter(pf["age"], pf["friend_count"])
plt.xlabel = "age"
plt.ylabel = "friends count"
plt.title = "Facebook Friends count by Age"
plt.show()
运行plt.scatter(pf["age"], pf["friend_count"]) 代码时,会显示散点图,但没有标签和标题。运行plt.show() 没有绘图,也没有显示错误。感谢任何帮助。
我为 Windows 操作系统安装了带有 Python 3 的 Anaconda。我的 Mac 笔记本电脑正在 Bootcamp 上运行。
【问题讨论】:
-
你在什么地方运行你的 Python 代码:PyCharm、Spyder、Canopy、Jupyter notebook、iPython、终端?
-
我在 Spyder 和 Jupyter notebook 中运行原始代码并得到相同的结果。我也在 Spyder 和 Jupyter 中尝试了你的代码。 Spyder 产生类似的结果,但 Jupyter 挂起(新窗口上的绘图没有响应)。
标签: python matplotlib plot anaconda spyder