如何调整子图中副标题和子图标题的位置

问题描述 投票:0回答:1

我创建了一个具有多个子图的图形。该图有其标题,每个子图都有其各自的标题。图标题使用

plt.suptitle('Test',size=20)
。在生成的图中,如下所示,图标题和第一个子图的标题相互重叠。如何解决这个问题。

生成相关图的主要代码如下,详细注释掉了。

plt.figure(figsize=(6*1, 4*6))
for i in range(6):
    plt.subplot(6,1,i+1)
    # the code for plotting the data are skipped
    plt.title('title for subplots',size=10)
plt.suptitle('Test',size=20)

python matplotlib subplot
1个回答
0
投票

matplotlib.pyplot.suptitle
x
y
参数允许您指定标题在图中的位置(文档here)。尝试从
y=1.0
开始(将
x
保留为其默认值
0.5
)并根据需要进行调整:

plt.suptitle('Test', size=20, y=1.0)
© www.soinside.com 2019 - 2024. All rights reserved.