How do I set my axis values down to zero when changing my y-axis to log scale?
Afficher commentaires plus anciens
I'm trying to get my y-axis to show log scale from 0-3, but whenever I change to log scale (from linear) it stops at about .5 or something like that. I've tried ylim and setting yticks and yticklabels and nothing I try seems to work. Help? The figure looks just how I want it to, except I want a label at zero so the rest of that error bar on the 2nd age bracket is shown.
figure(1)
clf
X=[1 2 3 4];
Y=[1 .7657621 .9677052 1.75706];
Yt=(0:.5:3);
L=(Y-[1 .5008611 .6634741 1.211559]);
U=([1 1.170767 1.411439 2.548182]-Y);
errorbar(X(2:4),Y(2:4),L(2:4),U(2:4),'sk',...
'linewidth',.5, ...
'markerfacecolor','k', ...
'markeredgecolor','k', ...
'markersize',8);
hold on; errorbar(X(1),Y(1),L(1),U(1),'*k',...
'markersize',8);
hold on; x=[.5 4.5]; y=[1 1]; plot(x,y,'--k')
ylim([0 3])
xlim([.5 4.5])
ylabel({'Odds-ratio';' '});
xlabel('Age bracket');
labelsx = {'\begin{tabular}{c} 18-24 \\(reference)\end{tabular}','25-31','32-38','39-45'};
set(gca,'XTick',X,'XTickLabel',labelsx,'TickLabelInterpreter', 'latex','Color',[1 1 1]);
set(gca,'yscale','log')
Thanks in advance for any help! Let me know if you need any more information.
Réponse acceptée
Plus de réponses (1)
There is no zero on log scale.
Add one line on the end of your code:
...
set(gca,'yscale','log')
ylim([0.4, 3])
Catégories
En savoir plus sur Axis Labels dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!