get(gca,'DataAspectRatio') does not refelct the real pixel ratio, and does not upate after stretching the figure window in default auto mode.
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi, I am using imagesc to show a matrix and want to get the aspect ratio of pixels at that time:
C = [0 2 4 6; 8 10 12 14; 16 18 20 22];
imagesc(C)
a = get(gca,'DataAspectRatio') % [2.0000 1.5000 1.0000] looks not close enough to real display.
aMode = get(gca,'DataAspectRatiomode') %auto
% however, after set the aspect ratio to its original value, the display changed:
set(gca,'DataAspectRatio',a)
% The initial aspect ratio value [2.0000 1.5000 1.0000] is more close to the 2nd image.
C = [0 2 4 6; 8 10 12 14; 16 18 20 22];
imagesc(C)
a = get(gca,'DataAspectRatio') % [2.0000 1.5000 1.0000]
aMode = get(gca,'DataAspectRatiomode') %auto
% I stretch the window, then retrieve the ratio again, but it still the same
a = get(gca,'DataAspectRatio') % [2.0000 1.5000 1.0000]
Why the initial retrieved aspect ratio does not reflect the displayed image and it does not update?
Thanks.
0 Kommentare
Antworten (1)
Walter Roberson
am 20 Okt. 2023
set(gca,'DataAspectRatio',a)
when you set the DataAspectRatio then DataAspectRatioMode is set to 'manual' -- but the mode must be 'auto' in order for stretch-to-fill behaviour to be active. This is pointed out clearly in daspect
0 Kommentare
Siehe auch
Kategorien
Mehr zu Read, Write, and Modify Image 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!