I'm trying to figure out how to fix the position of text in multiple subplots, where the x,y axes are changing. Below is a copy of my code. I've tried transforming the axes, but the code disappears altogether. I can't specify the values for x,y axes, because for some it becomes impossible to see the data.
fig, axs = plt.subplots(2, 3, figsize=(30,11))
#fig.suptitle('Basin ' + basin_number)
fig.suptitle('OFFSET = 5 ' + files[f][21:-7], fontsize=20 )
basin_name = files [f][21:-7]
#lim = min(axs[0,0])
#ylim = get(gca,'ylim')
#linear reg, Qb-Qt vs Qb-Qf
axs[0, 0].plot(XX,predict_mean_ci_low,'-',color='C0', label="95% Conf. Band for Slope")
axs[0, 0].plot(XX,predict_mean_ci_upp,'-',color='C0')
axs[0, 0].plot(XX,predict_ci_upp,'--',color='C8', label="95% Prediction Bands for response")
axs[0, 0].plot(XX,predict_ci_low,'--',color='C8')
axs[0, 0].plot(XX,YY,'.',color='C7')
axs[0, 0].plot(XX,fittedvalues,color='C1')
axs[0, 0].set_title('Linear Regression')
axs[0, 0].set_xlabel(r'$Q_b-Q_t$')
axs[0, 0].set_ylabel(r'$Q_b-Q_f$')
axs[0,0].legend(loc="upper left")
axs[0,0].text(1,-1, 'slope = {:.2f}\nr² = {:.2f}'.format(float(spp),float(r22)), bbox=dict(facecolor='white', alpha=0.5))
#axs[0,0].format(xlabel=r'$(Q_b-Q_t)/(\mathrm{max}|Q_b-Q_f|)$')
#transform=plt.gca().transAxes
# Qb vs time
axs[0, 1].plot(db.index,db.Qb, 'tab:orange')
axs[0, 1].set_title('$Q_b$ vs time')
axs[0, 1].set_xlabel('time')
axs[0, 1].set_ylabel(r'$Q_b$')
#Qt vs time
axs[1, 0].plot(db.index, db.Qt, 'tab:green')
axs[1, 0].set_title(r'$Q_t$ vs time')
axs[1, 0].set_xlabel('time')
axs[1, 0].set_ylabel(r'$Q_t$')
# Qf vs time
axs[1, 1].plot(db.index, db.Qf, 'tab:red')
axs[1, 1].set_title(r'$Q_f$ vs time')
axs[1, 1].set_xlabel('T=time')
axs[1, 1].set_ylabel(r'$Q_f$')
# dL/dt vs time
axs[0,2].plot(db.index, db.dLdt, 'tab:blue')
axs[0,2].set_title(r'$dL/dt$ vs time')
axs[0,2].set_xlabel('time')
axs[0,2].set_ylabel(r'$dL/dt$')
# Area vs time
axs[1,2].plot(db.index, db.A, 'tab:purple')
axs[1,2].set_title('Area vs time')
axs[1,2].set_xlabel('time')
axs[1,2].set_ylabel('Area')
plt.savefig('glacier_all_annual/OFFSET_5_basin_' + basin_name + '.png', format='png', dpi=150)
plt.show()
plt.close()
I've tried transforming axes, the text dissapears. I've tried setting parameters for x,y axes, but for some of our data it becomes too difficult to see.