how to set the evenly spaced yaxis

6 views (last 30 days)
NANDEESH
NANDEESH on 26 Sep 2017
Commented: Stephen23 on 30 Sep 2017
Hi I have an excel file with 12 columns and I am reading the data and plotting it as follows but I am getting unevenly spaced Yaxis( find the attached figure). Please give me suggestions to overcome it.
data = xlsread('PLOTF1');
x = data(:,1);
y=data(:,2);
loglog(x,y,'k','linewidth',2.0)
hold on
y2 = data(:,3);
loglog(x,y2,'b','linewidth',2.0)
hold on
y3 = data(:,4);
loglog(x,y3,'r','linewidth',2.0)
hold on
y4 = data(:,5);
loglog(x,y4,'b','linewidth',2.0)
hold on
y5 = data(:,6);
loglog(x,y5,'y','linewidth',2.0)
hold on
y6 = data(:,7);
loglog(x,y6,'g','linewidth',2.0)
hold on
y7 = data(:,8);
loglog(x,y7,'m','linewidth',2.0)
hold on
y8 = data(:,9);
loglog(x,y8,'y-.','linewidth',2.0)
hold on
y9 = data(:,10);
loglog(x,y9,'r-.','linewidth',2.0)
hold on
y10 = data(:,11);
loglog(x,y10,'k-+','linewidth',0.2)
hold on
y11 = data(:,12);
loglog(x,y11,'k-.','linewidth',2.0)
hold off
% ylabel('Stress, [MPa]','fontsize',20);
ylabel('NSD(dBVrms/sqrt(Hz))','fontweight', 'bold', 'fontsize',12, 'fontname',
'arial');
xlabel('Frequency (Hz)','fontweight', 'bold', 'fontsize',12, 'fontname', 'arial');
axis([0 500 -90 -10]);
I have also tried logspace and linespace functions.
  3 Comments
NANDEESH
NANDEESH on 26 Sep 2017
Edited: NANDEESH on 26 Sep 2017
Hi Stephen, In the plot you see the spacing between -10 and -20 is high
but the spacing in the lower scales -70,-80,-90 are spaced very close
So it is uneven.
I want the equal spacing between all the values
Stephen23
Stephen23 on 26 Sep 2017
Edited: Stephen23 on 26 Sep 2017
@NANDEESH: if you do not want a logarithmic y-scale then you should consider using another command, such as semilogx.

Sign in to comment.

Accepted Answer

NANDEESH
NANDEESH on 26 Sep 2017
Edited: NANDEESH on 26 Sep 2017
Hi,
I found the answer by changing the code
Instead of using loglog(x,y)
I used plot(x,y) then I set the gca of xaxis to log and yaxis to linear
plot(x,y,'k-.','linewidth',2.0);
set(gca,'YTick',[-90:10:-10]) ;
ax = gca;
ax.YScale = 'linear';
ax.XScale = 'log';
  1 Comment
Stephen23
Stephen23 on 30 Sep 2017
@NANDEESH@ using semilogx would be simpler. When you scroll to the bottom of loglog you will find a list of "See Also" functions, which you might like to spend a few minutes reading through the help of.

Sign in to comment.

More Answers (1)

KL
KL on 26 Sep 2017
Edited: KL on 26 Sep 2017
try
yticks([-90:10:-10])
  3 Comments

Sign in to comment.

Categories

Find more on Matrices and Arrays in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!