我最近不得不重新安装我的操作系统并决定切换到 Python3。随之而来的是我的 IDE PyCharm 的更新,大概还有 Matplotlib 的更新。
运行一个以前运行良好的脚本,现在给我的结果是丑陋的,我的子图标题重叠。
这是一个示例代码:
import numpy as np
import matplotlib.pyplot as plt
z = np.random.uniform(low=0, high=100, size=(20,4))
fig, axes = plt.subplots(2, 2, constrained_layout=True, sharey=True, sharex=True)
axes[-1, 0].set_xlabel('.\n', color=(0, 0, 0, 0))
axes[-1, 0].set_ylabel('.\n', color=(0, 0, 0, 0))
for s_plot, ax in enumerate(axes.flat):
ax.scatter(x=range(20), y=z[:,s_plot])
fig.suptitle("The Title\nSecond Line\n", fontsize=12)
plt.show()
我尝试设置constrained_layout
并False
尝试了subplots_adjust
,但它并没有改变我的地块布局。
我目前正在使用 matplotlib 3.0.2。有没有我错过的重大变化?我很困惑如何解决这个问题。