how to set the evenly spaced yaxis

16 vues (au cours des 30 derniers jours)
NANDEESH
NANDEESH le 26 Sep 2017
Commenté : Stephen23 le 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 commentaires
NANDEESH
NANDEESH le 26 Sep 2017
Modifié(e) : NANDEESH le 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 le 26 Sep 2017
Modifié(e) : Stephen23 le 26 Sep 2017
@NANDEESH: if you do not want a logarithmic y-scale then you should consider using another command, such as semilogx.

Connectez-vous pour commenter.

Réponse acceptée

NANDEESH
NANDEESH le 26 Sep 2017
Modifié(e) : NANDEESH le 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 commentaire
Stephen23
Stephen23 le 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.

Connectez-vous pour commenter.

Plus de réponses (1)

KL
KL le 26 Sep 2017
Modifié(e) : KL le 26 Sep 2017
try
yticks([-90:10:-10])
  3 commentaires
KL
KL le 26 Sep 2017
Ah, it's a log plot! Did you check a similar question answered by dpb here?
NANDEESH
NANDEESH le 26 Sep 2017
Thanks a lot KL :-)

Connectez-vous pour commenter.

Catégories

En savoir plus sur Matrices and Arrays dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by