How does axes property DataAspectRatio affect properties Position/TightInset
5 ビュー (過去 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!