How does axes property DataAspectRatio affect properties Position/TightInset
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (0)
Siehe auch
Kategorien
Mehr zu Graphics Object Properties finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!