How does axes property DataAspectRatio affect properties Position/TightInset
조회 수: 4 (최근 30일)
이전 댓글 표시
The documentation for getframe, explains how to calculate a margin so that captured image data includes the title, axis labels, and tick labels. The stated example works fine. However, if I set the axes DataAspectRatio property, this approach does not work anymore. For the specific example from the documentation,
plot(rand(5))
xlabel('x values')
title('Plot of Random Data')
set(gca, 'DataAspectRatio', [1 1 1]); % Added line
drawnow
ax = gca;
ax.Units = 'pixels';
pos = ax.Position;
ti = ax.TightInset;
rect = [-ti(1), -ti(2), pos(3)+ti(1)+ti(3), pos(4)+ti(2)+ti(4)];
F = getframe(ax,rect);
figure
imshow(F.cdata)
I get the following error:
Error using getframe (line 122)
The specified rectangle is not fully contained within the figure. MATLAB no longer supports this capability.
So the questions are:
- Why doesn't this approach work when DataAspectRatio is set?
- How can I calculate the margin that includes title, axis and tick labels, when DataAspectRatio is set?
댓글 수: 0
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Printing and Saving에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!