Script pos_in_Fig.m
Download Script pos_in_Fig.m
x=1:10;y=x.*x;plot(x,y),box off
%without and with the next three lines
set(get(gca,'XLabel'),'String','x values ')
set(get(gca,'YLabel'),'String',' y values')
set(gca,'Title',text('String','The Title string','Color','r'))

set(gca,'units','centimeters')
t_c= get(gca,'tightinset')

p = get(gca,'Position')
t = get(gca,'TightInset')

x = p(1)-t(1); y = p(2)-t(2);

w =p(3)+t(1)+t(3); h =p(4)+t(2)+t(4)

%Position
annotation('rectangle',p,...
'FaceAlpha',.2,'FaceColor','w','EdgeColor',...
'r','LineWidth',1.5);

%TighInset + Position
annotation('rectangle',[x,y,w,h],...
'FaceAlpha',.2,'FaceColor','w','EdgeColor',...
'r','LineWidth',1.5);

%Outer Position
annotation('rectangle',[0,0.007,0.995,0.99],...
'FaceAlpha',.2,'FaceColor','w','EdgeColor',...
'r','LineWidth',1.5);
Back