axis position and insets

조회 수: 5 (최근 30일)
Chad Greene
Chad Greene 2014년 8월 19일
답변: Chad Greene 2014년 8월 20일
I am having trouble getting insets to match the dimensions of my figure window. For any given figure I'd like to get the current position of axes and pin an inset to the upper left corner. Here is what I have tried:
gp = get(gca,'position');
axes('position',[gp(1) gp(2)+(.75)*gp(4) .25*gp(3) .25*gp(4)])
Unfortunately, this doesn't snap to my current figure axes:
I can manually adjust the figure size after plotting the inset and then it looks good:
But the manual solution is clunky and unrepeatable. Is there a way to get this inset pinned a little better?
  댓글 수: 2
dpb
dpb 2014년 8월 19일
Seems to work here if just use the above.
Any chance you've got a container that causes the position to be relative to it instead?
Otherwise, think need more detail to reproduce the problem/symptoms.
Chad Greene
Chad Greene 2014년 8월 20일
Ah, you're right, dpb, it does work with plain xy axes, but I am working with map axes. Unfortunately, there is no getm(gcm,'position'). Is there some equivalent? Matlab must know where it's putting those map axes.

댓글을 달려면 로그인하십시오.

채택된 답변

Chad Greene
Chad Greene 2014년 8월 20일
I found a perfect solution provided by Kelly Kearney. It's a wonderfully-written function and the syntax is straightforward:
gp = plotboxpos(gca);
axes('position',[gp(1) gp(2)+(.75)*gp(4) .25*gp(3) .25*gp(4)])

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Axis Labels에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by