<p>根据<a href="https://stackoverflow.com/a/40371037/2529760">https://stackoverflow.com/a/40371037/2529760</a>,您可以使用</p>
<pre class="lang-py prettyprint-override"><code>fig = plt.figure()
fig.patch.set_facecolor('white')
</code></pre>
<p>或者</p>
^{pr2}$
<p>在每个绘图的基础上强制在轴标签下使用白色背景。你可以用</p>
<pre class="lang-py prettyprint-override"><code>plt.rcParams['figure.facecolor'] = 'white'
</code></pre>
<p>以每个笔记本为基础实现这一点。在</p>
<p>要全局更改此设置,通常可以编辑matplotlibrc文件,但Jupyter似乎在某种程度上覆盖了此设置。在<a href="https://nbviewer.jupyter.org/github/mgeier/python-audio/blob/master/plotting/matplotlib-inline-defaults.ipynb" rel="nofollow noreferrer">https://nbviewer.jupyter.org/github/mgeier/python-audio/blob/master/plotting/matplotlib-inline-defaults.ipynb</a>之后,可以在包含行的正确位置(默认情况下是<code>~/.ipython/profile_default</code>)创建一个文件<code>ipython_kernel_config.py</code></p>
<pre class="lang-py prettyprint-override"><code>c.InlineBackend.rc = {'figure.facecolor': 'white'}
</code></pre>
<p>这些选项中的任何一个都将确保绘图背景为白色,因此文本清晰易读。在</p>
<p><a href="https://i.stack.imgur.com/OlkIA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OlkIA.png" alt="Demo image"/></a></p>