在IPython Notebook中自动内联运行%matplotlib

在IPython Notebook中自动内联运行%matplotlib,第1张

在IPython Notebook中自动内联运行%matplotlib 配置方式

IPython的配置文件位于

~/.ipython/profile_*
。默认配置文件称为
profile_default
。在此文件夹中,有两个主要配置文件:

  • ipython_config.py
  • ipython_kernel_config.py

将matplotlib的内联选项添加到

ipython_kernel_config.py

c = get_config()# ... Any other configurables you want to setc.InteractiveShellApp.matplotlib = "inline"
matplotlib与pylab

不鼓励使用

%pylab
inline进行绘图

它将各种不需要的杂项引入您的名称空间。

%matplotlib
另一方面,无需插入名称空间即可启用内联绘图。您需要进行显式调用才能导入matplotlib和numpy。

import matplotlib.pyplot as pltimport numpy as np

现在,您已经拥有可复制的代码,因此可以完全克服显式输入导入的低价格。



欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zaji/5643953.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-12-16
下一篇2022-12-16

发表评论

登录后才能评论

评论列表(0条)

    保存