split title of a figure in matplotlib

后端 未结 5 1315
温柔的废话
温柔的废话 2020-12-24 06:35

I use matplotlib to create a figure with 4 sub-plots in it.

I would like to split one of my title of a subplot, such that each line would be in the centered with res

5条回答
  •  悲哀的现实
    2020-12-24 07:13

    I get the correct alignment when I format the string this way:

    import matplotlib.pylab as plt
    
    fig = plt.figure()#num=0,figsize=(8.27, 11.69), dpi=300)
    ax  = fig.add_subplot(2, 2, 1)
    ax.set_title('Normalized occupied \n Neighbors')
    
    plt.show()
    

    enter image description here

提交回复
热议问题