Row titles for matplotlib subplot

前端 未结 2 1894
一个人的身影
一个人的身影 2020-12-03 17:31

In matplotlib, Is it possible to set a a separate title for each row of subplots in addition to the title set for the entire figure and the title set for each individual plo

相关标签:
2条回答
  • 2020-12-03 18:14

    Another easy cheat is to give the title of the middle column as subplot row XX\n\nPlot title No.YY

    0 讨论(0)
  • 2020-12-03 18:24

    An idea is to create three "big subplots", to give each of them a title, and make them invisible. On the top of that you can create your matrix of smaller subplots.

    This solution is entirely based on this post, except that more attention has been paid to actually removing the background subplot.

    enter image description here

    import matplotlib.pyplot as plt
    
    fig, big_axes = plt.subplots( figsize=(15.0, 15.0) , nrows=3, ncols=1, sharey=True) 
    
    for row, big_ax in enumerate(big_axes, start=1):
        big_ax.set_title("Subplot row %s \n" % row, fontsize=16)
    
        # Turn off axis lines and ticks of the big subplot 
        # obs alpha is 0 in RGBA string!
        big_ax.tick_params(labelcolor=(1.,1.,1., 0.0), top='off', bottom='off', left='off', right='off')
        # removes the white frame
        big_ax._frameon = False
    
    
    for i in range(1,10):
        ax = fig.add_subplot(3,3,i)
        ax.set_title('Plot title ' + str(i))
    
    fig.set_facecolor('w')
    plt.tight_layout()
    plt.show()
    
    0 讨论(0)
提交回复
热议问题