Adding a second x_axis entry above the header

How do I move my subheading title so that the second axis does not write to the top title, but below instead? This is what it looks like

enter image description here

And here's a piece of code:

    # fig is a subplotAxes object
    fig.set_ylabel('Altitude (km)')
    fig.set_xlabel('Time')   
    fig.get_xaxis().set_major_formatter(mpl.dates.DateFormatter('%H:%M:%S'))

    cbar_label = 'Total Attenuated Backscatter 532nm (km$^{-1}$ sr$^{-1}$)'
    cbar = pfig.colorbar(im)
    cbar.set_label(cbar_label)

    # create second axis
    ax2 = fig.twiny()
    ax2.set_label('Latitude')
    ax2.set_xlim(latitude[0], latitude[-1])

    # set title, but title is overwritten
    fig.set_title("Averaged 532 nm Total Attenuated Backscatter")

      

I don't know if this could be the reason for my shape size or a simple formatting error. I would not like to expand the size of the shape as this plot lives inside a Tkinter window

+3


source to share


3 answers


Since your heading applies to the entire figure, not just the subheading, @ GyΓΆrgy Solymosi's answer is probably the way to go (instead of adding a newline, which is kind of a hack).

Alternatively, you can move the title text to wherever you want it, eg. raising it by 5%:



title = fig.set_title("Flying monkey density")
title_xy = title.get_position()
title.set_position([title_xy[0], title_xy[1]*1.05])

      

+2


source


Try fig.suptitle("Averaged 532 nm Total Attenuated Backscatter")



+1


source


This solution was way easier than I ever imagined, I feel stupid. All I had to do was add \n

to the end of the title

 fig.set_title("Averaged 532 nm Total Attenuated Backscatter\n")

      

enter image description here

+1


source







All Articles