Turbotanten
Turbotanten

Reputation: 25

How to calibrate axis in Matlab?

Hello people of the interwebs!

My question is pretty simple. I want to change the horizontal and vertical axis scale? As you can see en the picture below I would like to have the value 1332 instead of ~ 3750 where you see a very clear blue line. How do I achieve this?

enter image description here

I appreciate all the help I can get!

Thanks in advance! :)

Upvotes: 0

Views: 857

Answers (1)

am304
am304

Reputation: 13876

The values on the axis are based on your data, so the best option would really be to scale the data you plot, e.g. instead of plotting:

plot(x,y,'b.')

plot something like:

plot(x*1332/3750,y*1332/3750,'b.') % assuming same scaling factor on both axes

The other option, which is not so good in my opinion, is to change the axes ticks after plotting:

current_xticks = get(gca,'XTick');
new_xticks = current_xticks * 1332,3750;
set(gca,'XTick',new_xticks);
current_yticks = get(gca,'YTick');
new_yticks = current_yticks * 1332,3750; % assuming same scaling factor on both axes
set(gca,'YTick',new_yticks);

Upvotes: 2

Related Questions