Question

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)');
Était-ce utile?

La solution

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
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top