在Jupyter Notebook上,%matplotlib内联在有或没有它的情况下给出的结果相同 [英] %matplotlib inline gives the same result with or without it on Jupyter Notebook

查看:108
本文介绍了在Jupyter Notebook上,%matplotlib内联在有或没有它的情况下给出的结果相同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我经历了有关在Jupyter Notebook中使用%matplotlib内联函数的一些问题,我知道%matplotlib内联将matplotlib的后端设置为'inline'后端"& 使用'inline'后端时,matplotlib图形将包含在笔记本中的代码旁边".但是,无论是否使用%matplotlib inline",我的绘图结果都看不到任何差异.如果我误解了某人,可以给我解释一下吗?这是我尝试过的简单代码:

So I went through some questions being posted about the usage of %matplotlib inline function in Jupyter Notebook, I do understand that "%matplotlib inline sets the backend of matplotlib to the 'inline' backend" & "When using the 'inline' backend, your matplotlib graphs will be included in your notebook, next to the code". But, I don't see any difference in my plot results with or without the use of "%matplotlib inline". Can someone explain this to me if I am misunderstanding something? Here's a simple code I have tried:

内嵌%matplotlib的图形

%matplotlib inline
import matplotlib as mpl
import matplotlib.pyplot as plt

plt.plot([[0,0],[1,1]], linewidth=4, label='random diagonal')

在下一个代码中,我刚摘下%matplotlib内联给仍然给我相同的结果.那么,是否使用%matplotlib inline"功能有什么意义呢?

In the next code, I just took off the %matplotlib inline and it gives still gives me the same result. What is the point of using or not using the "%matplotlib inline" function then?

推荐答案

感谢@ImportanceOfBeingErnest,他认为问题出在笔记本后端已经设置为嵌入式.一旦运行代码matplotlib.get_backend(),您可以看到笔记本中的后端默认情况下已设置为内联.我猜这在Anaconda的Python 3.7版本的笔记本电脑中现在是默认设置.

Thanks to @ImportanceOfBeingErnest, figured that the problem comes from the notebook backend already set to inline. Once you run the code matplotlib.get_backend(), you can see the backend within the notebook is already set to inline by default. I am guessing this comes as a default now in Anaconda's version of Python 3.7's notebooks.

这篇关于在Jupyter Notebook上,%matplotlib内联在有或没有它的情况下给出的结果相同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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