擅长:python、mysql、java
<h2>配置方式</h2>
<p>IPython的配置配置文件位于<code>~/.ipython/profile_*</code>。默认配置文件名为<code>profile_default</code>。此文件夹中有两个主配置文件:</p>
<ul>
<li><code>ipython_config.py</code></li>
<li><code>ipython_kernel_config.py</code></li>
</ul>
<p>将matplotlib的inline选项添加到<code>ipython_kernel_config.py</code>:</p>
<pre><code>c = get_config()
# ... Any other configurables you want to set
c.InteractiveShellApp.matplotlib = "inline"
</code></pre>
<h2>matplotlib对pylab</h2>
<p>使用<code>%pylab</code>获得内联绘图是<a href="https://carreau.github.io/posts/10-No-PyLab-Thanks.html" rel="noreferrer">discouraged</a>。</p>
<p>它会在你的名称空间中引入各种你不需要的东西。</p>
<p>另一方面,<code>%matplotlib</code>启用内联打印而不插入命名空间。您需要执行显式调用才能导入matplotlib和numpy。</p>
<pre><code>import matplotlib.pyplot as plt
import numpy as np
</code></pre>
<p>显式地输入导入的小代价应该完全被这样一个事实所克服:您现在有了可复制的代码。</p>