World coordinates XY scale

조회 수: 1 (최근 30일)
Brian
Brian 2020년 5월 1일
댓글: Brian 2020년 5월 1일
Hi Matlab Answers,
I'm trying to plot a spacetime image with positions on the y-axis and time on the x-axis.
When displaying the image using
imshow(ST_image);
axis on;
% size(ST_image) = [500 512]
the display is 1:500 x 1:512, as expected.
When trying to change to physical dimensions, e.g.
Space_limits = [40 60]; % mm
Time_limits = [-0.01 0.1] %s
the axes are on very different scales. This causes the displayed figure to collapse the image to effectively a vertical line and I can't seem to get it to reshape.
I've tried imref2D for world coordinates, setting the XData, YData properties, scaling the axes aspect ratio, etc. I'm sure this is just a figure and/or axes property that I'm missing, but would be very grateful if somebody knew offhand.
ST_ref = imref2d(size(ST_image))
ST_ref.XWorldLimits = Time_limits;
ST_ref.YWorldLimits = Space_limits;
f = figure;
imshow(ST_image,ST_ref); axis on;
%f.XData = Time_limits;
%pbaspect([1 1 1])
Thanks for your help!

채택된 답변

Kelly Kearney
Kelly Kearney 2020년 5월 1일
The imshow function automatically sets the DataAspectRatio to be [1 1 1], i.e. the same effect as axis equal. To undo this, set the mode back to manual.
set(gca, 'DataAspectRatioMode', 'auto');
  댓글 수: 1
Brian
Brian 2020년 5월 1일
This is perfect! Thanks Kelly so much for your help!
For future users, this is what worked for me based on Kelly's answer:
set(gca,'DataAspectRatioMode','manual')
set(gca,'DataAspectRatio',[0.005 1 1])

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Lighting, Transparency, and Shading에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by