0

I want to display an image with axes that has a different vertical and horizontal scale. The following code gives me an image that is very long and thin. If I multiply the scale of the y-axis by 250 (commented line) I get the aspect ratio of the image I want but now the scale on the y-axis is wrong.

A = rand(100,400);
A_image = mat2gray(A);
A_image = imresize(A_image,2);

RI = imref2d(size(A_image),[0 800],[-1 1]);
%RI = imref2d(size(A_image),[0 800],250*[-1 1]);

figure(1);
imshow(256*A_image,RI,jet)
xlabel('$t$ (s)');
ylabel('$z$ (m)');

1 Answer 1

2

Changing the world reference changes the axis labels to match that world reference, but you can always change the labels back.

xlabels=get(gca,'XTickLabels'); % //this will get your current labels;
nlabels=length(xlabels); % //Get how many we need
new_xlabels=linspace(-1,1,nlabels); % //Create a linear space at each label point
set(gca,'XTickLabels',new_xlabels); % //apply the new labels

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.