Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rescaling Y axis in a plot

I am trying to adjust the y axis and change it to be from [0 2.5] and to show that it has to be multiplied by a factor of 1000.

Obviously setting the limit with ylim=([0 25]) doesn't work and I can't find a way to do it.

image

Using to plot:

AveTime = 1.0e+03 * [0.0020, 0.0291, 0.1279, 0.3061, 2.0599];
STDtime = [0.0519, 0.0117, 0.0166, 0.0071, 0.0165];
errorbar([10,25,50,75,100], AveTime, STDtime);
like image 924
Tony Tannous Avatar asked Feb 26 '26 23:02

Tony Tannous


1 Answers

I believe this is what you need, it should work for Matlab versions >= 2014b:

ax = gca;
ax.YAxis.Exponent = 3;

Here's a code example:

clear;
close all;
clc;

x=1:10:1000;
y=3*x;
plot(x,y);
ax = gca;
ax.YAxis.Exponent = 3;

And the plot:

enter image description here

like image 154
David Avatar answered Feb 28 '26 13:02

David



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!