How to define the upper limit of y-scale in a log plot
조회 수: 49 (최근 30일)
이전 댓글 표시
Hello, i need to plot some graphs of some curves in logarithmic scale on the y-axis and the y-scale must range from 0 to 10^-5. I want to superpose the curves on the same image, thats why the scale must be the same for all plots. I'm currently using semilogy to get a log scale, but the range is completely messed up. I've tryed using
set(gca,'yscale','log')
but again, i don't have control on the upper limits of the y-scale. What can i use to resolve this? Thanks.
댓글 수: 0
답변 (3개)
dpb
2015년 9월 4일
You don't give any data nor attach a plot to see the issue specifically, but you set fixed axes limits on log axes the same way as you do for linear ones--use ylim (or set for low-level control or in conjunction with other properties on the axes in one call).
Simple example--
y=[10*rand(10,1), 1E5*rand(10,1)];
hAx=semilogy(y);
ylim([1,1E6])
ylim([.5,4E5])
Salt to suit for your particular case...
댓글 수: 0
Heyang Qin
2019년 1월 12일
The problem of cannot set axis range such as ylim or xlim in log scale is becaue you cannot set log value to 0. Any value other than 0 will work.
댓글 수: 0
Meirbek Mussatayev
2022년 11월 19일
Hi,
Please try this code:
set(gca, 'YScale', 'log')
ylim([0 1e-5])
댓글 수: 0
참고 항목
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!