python - %matplotlib 内联与 ​​%matplotlib 笔记本在 pythonAnywhere jupyter 中的显示问题

标签 python matplotlib jupyter pythonanywhere

这不是建议的重复。我不是要切换后端。我只是想使用 %matplotlib notebook公式。此外,在另一个问题中建议的解决方案(将 %matplotlib notebook 放在 from matplotlib import pylplot as plt 之前或尝试连续两次调用魔术命令)对我不起作用。行为(空白笔记本图表)仍然存在。

放置 %matplotlib notebook之前from matplotlib import pylplot as plt或者尝试连续两次调用魔法命令

当我使用 %matplotlib inline我的图表总是显示,但它们通常很小,并且无法缩放/平移。

当我使用 %matplotlib notebook我得到了可缩放、可平移的图表,但有时我会遇到图表显示为空白的问题。

enter image description here

背景:

PythonAnywhere 笔记本 3.6 Python。从 Windows 7 使用更新 Google Chrome。

如果我重新打开我现有的笔记本,甚至重新启动内核并重新运行所有单元格,我所有的 .plot()出现空白。但是如果我同时启动一个全新的 3.6 笔记本,%matplotlib notebook情节工作正常。杀死所有与 jupyter 相关的进程也无济于事。

这并不总是发生。但是,如果一张图表显示为空白,则它们都显示为空白。

我想用notebook魔法,但这个问题相当深刻。

enter image description here

最佳答案

我在使用 %matplotlib 时发现了一些稳定性笔记本,包括 plt.close() 之后,在我所有的情节之前。

我知道这是一个非常肮脏的解决方案,但它有效。这里是 Windows 10、Python 3.6.2 和 Jupyter 6.03(更新后的 Jupyter 还没有解决问题)。
希望这可以帮助。

关于python - %matplotlib 内联与 ​​%matplotlib 笔记本在 pythonAnywhere jupyter 中的显示问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48055819/

相关文章:

python - matplotlib 颜色图 : set_bad doesn't have an impact with collections

jupyter-notebook - 我可以自动保存正在运行的 jupyter python 笔记本而不在浏览器选项卡中打开它吗?

jupyter 相对图像路径中的 Markdown

python - Pandas 散点图 : how to plot data on a secondary y axis?

python - 正确使用 Matplotlib 的 pick 事件

python - 使用 jupyter notebook 运行选定的行并显示输出

python - 如何让 scons 调用外部脚本?

python - 在没有脚本文件的情况下从命令行执行python程序

Python 日期 - 迭代列名称

python - 如何更改 Plone 3 中的 "Event"portlet