1.设置图片大小
set(gcf,'unit','centimeters','position',[10 5 4 3])
按照自己需求修改【10 5 4 3】中的【4 3】
2.改变标签长度、以及隐藏标签背景
leg=legend([h1,h2],'1','2');
leg.ItemTokenSize = [12,16];
legend("boxoff")
3.设置坐标轴范围、字号
set(gcf,'unit','centimeters','position',[10 5 4 3])
set(gca, 'Xlim' ,[0 25],'Ylim' ,[-0.3 0.3])
yticks([-0.3 -0.2 -0.1 0 0.1 0.2 0.3])
4.绘制坐标轴右侧
XL = get(gca,'xlim'); XR = XL(2);
YL = get(gca,'ylim'); YT = YL(2);
plot(XL,YT*ones(size(XL)),'Color', 'k')
plot(XR*ones(size(YL)),YL,'Color', 'k')
5.删除坐标轴周围多余空白
set(gca, 'LooseInset', [0,0,0.01,0]);