且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

带有子图的多个标题(字幕)

更新时间:2023-09-22 15:33:46

您可以修改标题和标签.检查以下根据您的代码改编的示例:

You can tinker with the titles and labels. Check the following example adapted from your code:

import matplotlib.pyplot as plt

fig, axes = plt.subplots(3,3,sharex='col', sharey='row')

counter = 0
for j in range(9):
    if j in [0,3,6]:
        axes.flat[j].set_ylabel('Row '+str(counter), rotation=0, size='large',labelpad=40)
        axes.flat[j].set_title('plot '+str(j))
        counter = counter + 1
    if j in [0,1,2]:
        axes.flat[j].set_title('Column '+str(j)+'\n\nplot '+str(j))
    else:
        axes.flat[j].set_title('plot '+str(j))

plt.show()

,结果为: