Hey I try to savefig my plot, but it allways cuts off my title. I think it is because of y=1.05 (to set a distance to the title). I can not fix it. Is there a way to save the entire graph?
time=round(t[time_period],0)
most_sensitive=sorted(most_sensitive)
plt.figure(figsize=(10, 5))
plt.suptitle("Scatterplot "+str(name)+" , "+r'$\Delta$'+"Output , Zeit= "+str(time)+" s",fontsize=20,y=1.05)
figure_colour=["bo","ro","go","yo"]
for i in [1,2,3,4]:
ax=plt.subplot(2,2,i)
plt.plot(parm_value[:,most_sensitive[i-1]], Outputdiff[:,most_sensitive[i-1]],figure_colour[i-1])
ax.set_xlabel(name+"["+str(most_sensitive[i-1])+"] in "+str(unit))
ax.set_ylabel(r'$\Delta$'+"Output")
lb, ub = ax.get_xlim( )
ax.set_xticks( np.linspace(lb, ub, 4 ) )
lb, ub = ax.get_ylim( )
ax.set_yticks( np.linspace(lb, ub, 8 ) )
ax.grid(True)
plt.tight_layout()
newpath = r'C:/Users/Tim_s/Desktop/Daten/'+str(name)+'/'+str(time)+'/'+'scatterplot'+'/'
if not os.path.exists(newpath):
os.makedirs(newpath)
savefig(newpath+str(name)+'.png')
I don't know if my scenario was the same as yours, but I solved my issue by adding the parameter bbox_inches='tight'
to the savefig
call.
That may be valuable for people that stumble on this question given its title. It would have been for me...