axis command fails for log scale
조회 수: 5 (최근 30일)
이전 댓글 표시
figure
plot([1 2], [1 2])
axis([0 3 0 3])
axis(gca)
set(gca,'yscale','log')
%axis auto
axis(gca)
The second axis command does not return the correct value. It returns zero for the min Y axis limit, and does not reflect any of the changes from switching to the log scale. Including the axis auto function is a partial workaround for this example, but for some reason does not work the same way in my (very complicated) example.
댓글 수: 0
답변 (2개)
Jan
2018년 1월 22일
It is not the axis command, which fails, but the axes contains the wrong values.
ax = axes;
plot([1 2], [1 2]);
ax.YLim = [0, 3];
ax.YScale = 'log';
drawnow;
ax.YLim % Returns: 0 3
But the displayed range is [1, 3]. This seems to be a bug.
The workaround is easy: Either let Matlab set the Y-limits automatically or write you own function, which avoids to set the Y-limit of a log-scaled axis to the impossible value 0.
참고 항목
카테고리
Help Center 및 File Exchange에서 Exponents and Logarithms에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!