我有以下代码不起作用:
import matplotlib.pyplot as plt
# Make the plot
fig, axs = plt.subplots(3, 1, figsize=(3.27, 6))
axs[0].plot(range(5), range(5), label='label 1')
axs[0].plot(range(5), range(4, -1, -1), label='label 2')
axs[0].legend(bbox_to_anchor=(0, 1.1, 1., 0.1), mode='expand', ncol=2, frameon=True, borderaxespad=0.)
# Adjust subplots to make room
fig.subplots_adjust(top=.5)
fig.savefig('test.png', format='png', dpi=300)
可以看出 fig.subplots_adjust 根本不起作用。
我正在使用 WinPython 3.3.2.3 64 位,matplotlib 版本 1.3.0 和 CPython 3.3。这发生在 IPython Notebook 中。后端是在线的。笔记本的输出是完整的,但是输出文件被不正确地裁剪。在笔记本和保存的文件中, subplots_adjust 命令无效。