Automatic Axes Resize behavior
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi
Just a simple question, it seems that for 3D figures the position and outerposition of the axes do not quite match with what is explained in the following documnetation link: http://www.mathworks.se/help/techdoc/creating_plots/f1-32495.html
As I ran a very simple code to get the extent of the axes:
function DmnstrBrdrFg
plot3(1:5,1:5,1:5)
set(gca,'XTickLabel',[],'YTickLabel',[],'ZTickLabel',[])
Ps= get(gca,'Position');
OPs= get(gca,'OuterPosition');
PltBrdr(Ps,'P')
PltBrdr(OPs,'O')
function PltBrdr(Ps,Chr)
FndDtPnts(Ps(1),Ps(2),Chr,1);
FndDtPnts(Ps(1)+Ps(3),Ps(2),Chr,2);
FndDtPnts(Ps(1)+Ps(3),Ps(2)+Ps(4),Chr,3);
FndDtPnts(Ps(1),Ps(2)+Ps(4),Chr,4);
function Out=FndDtPnts(Ps1,Ps2,Chr,Id)
text(Ps1,Ps2,[Chr '_'num2str(Id)],'Unit','normalized','Visible','on');
As it seems the corners of OuterPosition point at where it is supposed to be the corners of Position and I don't know what are the corners where Position point at.
Any idea?
Best regards Afshin
댓글 수: 0
채택된 답변
Sean de Wolski
2012년 7월 16일
The normalized region for the text is at the outer border of the position. To get it further out, you have to work outside the range of [0 1]. Consider somehting liek this:
function DmnstrBrdrFg
plot3(1:5,1:5,1:5)
set(gca,'XTickLabel',[],'YTickLabel',[],'ZTickLabel',[])
Ps= get(gca,'Position');
OPs= get(gca,'OuterPosition');
set(gcf,'activepositionproperty','outerposition');
PltBrdr(Ps,'P')
PltBrdr2(OPs,'O')
function PltBrdr(Ps,Chr)
FndDtPnts(Ps(1),Ps(2),Chr,1);
FndDtPnts(Ps(1)+Ps(3),Ps(2),Chr,2);
FndDtPnts(Ps(1)+Ps(3),Ps(2)+Ps(4),Chr,3);
FndDtPnts(Ps(1),Ps(2)+Ps(4),Chr,4);
function Out=FndDtPnts(Ps1,Ps2,Chr,Id)
text(Ps1,Ps2,[Chr '_' num2str(Id)],'Unit','normalized','Visible','on');
function PltBrdr2(Ps,Chr)
FndDtPnts(Ps(1)-.1,Ps(2)-.1,Chr,1);
FndDtPnts(Ps(1)+Ps(3)+.1,Ps(2)-.1,Chr,2);
FndDtPnts(Ps(1)+Ps(3)+.1,Ps(2)+Ps(4)+.1,Chr,3);
FndDtPnts(Ps(1)-.1,Ps(2)+Ps(4)+.1,Chr,4);
function Out=FndDtPnts2(Ps1,Ps2,Chr,Id)
text(Ps1,Ps2,[Chr '_' num2str(Id)],'Unit','normalized','Visible','on');
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Line Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!