Search code examples
pythonimagematplotlibplotfigure

How to make more room for subplot text fields in Python's matplotlib?


How to make more room for subplot text fields in Python's matplotlib? Now it looks too messy: some of the text fields are going over each other.

Here is a part of the current code for the figure:

    fig_a = fig.add_subplot(2,2,i)
    fig_a.set_title(r'$T_{0} = %.3g N/m, V_{0} = %.6g$ m/s' % (counter, V0))
    fig_a.plot(xx,f)
    plt.xlim(-kappa,kappa)
    plt.xlabel(r'$\eta$')
    plt.ylim(-0.1,1.1)
    if ((i == 1) or (i == 3)):
        plt.ylabel(r'$f(\eta)$')
    i = i + 1

How to change it to not to look so messy?


Solution

  • fig.subplots_adjust(left=None, bottom=None, right=None, top=None, wspace=None, hspace=None)
    

    You're going to want to modify hspace, the vertical space between subplots: I found hspace=0.4 looked okay with your code, but YMMV.