擅长:python、mysql、java
<p>始终在<code>Figure</code>和<code>Axes</code>对象上显式直接操作。不要依赖于<code>pyplot</code>状态机。就你而言,这意味着:</p>
<pre><code>fig1, ax1 = plt.subplots(figsize=(10,4))
df['A'].plot(ax=ax1)
fig1.savefig("plot1.png")
fig2, ax2 = plt.figure(figsize=(10,4))
df[['A', 'B']].plot(ax=ax2)
fig2.savefig("plot2.png")
plt.show()
</code></pre>