%matplotlib 笔记本显示空白直方图 [英] %matplotlib notebook showing a blank histogram

查看:41
本文介绍了%matplotlib 笔记本显示空白直方图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的 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.

所以解决方案是要么重启内核,要么启动一个新的 notebook.

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆