%matplotlib笔记本显示空白直方图 [英] %matplotlib notebook showing a blank histogram
问题描述
在我的Jupyter笔记本中,我现在使用的是%matplotlib notebook
而不是%matplotlib inline
,现在可以与我在Jupyter上的绘图进行交互了.但是,当我尝试制作直方图时,会得到一个空白图:
In my Jupyter notebook I am now using %matplotlib notebook
instead of %matplotlib inline
, it's awesome that I can now interact with my plots on Jupyter. However, when I try to make an histogram I get a blank plot:
如果我使用%matplotlib inline
,则一切正常:
If I use %matplotlib inline
everything works fine:
这是怎么回事?
推荐答案
看到我上面的评论确实帮助某人解决了问题,我将其发布为答案.
Seeing that my comment above has indeed helped someone to solve the problem I will post it as an answer.
如果在不重新启动内核的情况下从%matplotlib inline
切换到%matplotlib notebook
,则会出现问题.
The problem occurs if you switch from %matplotlib inline
to %matplotlib notebook
without restarting the kernel.
从%matplotlib notebook
切换到%matplotlib inline
可以正常工作.
Switching from %matplotlib notebook
to %matplotlib inline
works fine.
因此解决方案是重新启动内核或启动新笔记本.
So the solution is to either restart the kernel or start a new notebook.
在某些情况下,它似乎有助于重复笔记本后端的设置,即像这样两次调用它
It seems that in some cases it helps to repeat the setting of the notebook backend, i.e. call it twice like
%matplotlib notebook
%matplotlib notebook
在此评论中找到的原因的分析
An analysis for why that is can be found in this comment
这篇关于%matplotlib笔记本显示空白直方图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!