gpt4 book ai didi

Python:Savefig 截断标题

转载 作者:太空狗 更新时间:2023-10-29 21:52:18 27 4
gpt4 key购买 nike

嘿,我试着保存我的情节,但它总是切断我的头衔。我认为这是因为 y=1.05(设置与标题的距离)。我无法修复它。有没有办法保存整个图?

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')

最佳答案

我不知道我的情况是否与您的相同,但我通过将参数 bbox_inches='tight' 添加到 savefig 调用中解决了我的问题。

鉴于标题,这对于偶然发现此问题的人来说可能很有值(value)。对我来说……

关于Python:Savefig 截断标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35992492/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com