how to set the evenly spaced yaxis

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 Commenti

@nandeesh kumaravelu: what evenly-spaced tick marks do you expect to see on a logarithmic scale between -90 and -10 ?
NANDEESH
NANDEESH il 26 Set 2017
Modificato: NANDEESH il 26 Set 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 il 26 Set 2017
Modificato: Stephen23 il 26 Set 2017
@NANDEESH: if you do not want a logarithmic y-scale then you should consider using another command, such as semilogx.

Accedi per commentare.

 Risposta accettata

NANDEESH
NANDEESH il 26 Set 2017
Modificato: NANDEESH il 26 Set 2017

0 voti

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 Commento

@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.

Accedi per commentare.

Più risposte (1)

KL
KL il 26 Set 2017
Modificato: KL il 26 Set 2017
try
yticks([-90:10:-10])

3 Commenti

Hi, Thanks for the reply
I tried yticks,
set(gca,'YTick'[-90:10:-10];
but still it is not working
KL
KL il 26 Set 2017
Ah, it's a log plot! Did you check a similar question answered by dpb here?
Thanks a lot KL :-)

Accedi per commentare.

Categorie

Scopri di più su Graphics Performance in Centro assistenza e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by