擅长:python、mysql、java
<p>在您的例子中,您可能需要重塑图形窗口以适应内容的形状。对于方形窗口,可以使用:</p>
<pre><code>fig = figure(figsize=(6, 6)) # width and height in inches
fig.tight_layout(pad=0.5) # distance betweeen the axis and the figure edge
</code></pre>
<p>如果需要,请确保为轴标签保留一些空间。如果你只想改变背景颜色,@JoeKington的评论就是答案。在</p>
<p><a href="http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.tight_layout" rel="nofollow">http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.tight_layout</a></p>